// File: /workspace/github_c_makefile_star2_O2/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 0xf4de6
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 0xf4e14
movq 0xc8(%r14), %rcx
testq %rcx, %rcx
movq %rdx, (%rsp)
je 0xf4b8e
movq 0x80(%r14), %rdi
movq (%rdi), %rsi
movq 0x10(%rdi), %rdi
shlq $0x4, %rdi
cmpq %r12, -0x8(%rsi,%rdi)
jae 0xf4ea4
addq %r12, %rax
subq %rax, %rbp
addq %rbp, %rcx
cmpq 0xa8(%r14), %rcx
jb 0xf4b94
movq %r14, %rdi
callq 0xf4282
movb $0x0, 0xd4(%r14)
jmp 0xf4b94
addq %r12, %rax
subq %rax, %rbp
movq 0xa8(%r14), %r15
cmpq %r15, %rbp
jbe 0xf4ca7
movb $0x0, 0xd4(%r14)
movl 0xd0(%r14), %r13d
movq 0x80(%r14), %rcx
movq 0x8(%rcx), %rsi
cmpq %rsi, 0x10(%rcx)
jae 0xf4bc9
movq (%rcx), %rax
jmp 0xf4bf3
addq $0xa, %rsi
movq %rsi, 0x8(%rcx)
movq (%rcx), %rdi
shlq $0x4, %rsi
leaq 0x230814(%rip), %rdx    # 0x3253f3
movl $0x1c7, %ecx            # imm = 0x1C7
callq 0x93472
movq 0x80(%r14), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0xf4d80
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 0xf4c38
movq (%rcx), %rax
jmp 0xf4c66
leaq 0xa(%rax), %rdx
movq %rdx, 0x8(%rcx)
movq (%rcx), %rdi
leaq 0x50(,%rax,8), %rsi
leaq 0x2307a1(%rip), %rdx    # 0x3253f3
movl $0x1c8, %ecx            # imm = 0x1C8
callq 0x93472
movq 0x88(%r14), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0xf4dae
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 0xf4282
movq 0xa8(%r14), %r15
subq %r15, %rbp
addq %r15, %r12
jmp 0xf4b9b
movq 0x80(%r14), %rcx
movq 0x8(%rcx), %rsi
cmpq %rsi, 0x10(%rcx)
jae 0xf4cbd
movq (%rcx), %rax
jmp 0xf4ce7
addq $0xa, %rsi
movq %rsi, 0x8(%rcx)
movq (%rcx), %rdi
shlq $0x4, %rsi
leaq 0x230720(%rip), %rdx    # 0x3253f3
movl $0x1d3, %ecx            # imm = 0x1D3
callq 0x93472
movq 0x80(%r14), %rcx
movq %rax, (%rcx)
movq (%rsp), %rdi
testq %rax, %rax
je 0xf4e42
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 0xf4d23
movq (%rcx), %rax
jmp 0xf4d51
leaq 0xa(%rax), %rdx
movq %rdx, 0x8(%rcx)
movq (%rcx), %rdi
leaq 0x50(,%rax,8), %rsi
leaq 0x2306b6(%rip), %rdx    # 0x3253f3
movl $0x1d4, %ecx            # imm = 0x1D4
callq 0x93472
movq 0x88(%r14), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0xf4e73
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
movq 0x3431e1(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f0282(%rip), %rsi    # 0x2e5013
leaq 0x2307d9(%rip), %rdx    # 0x325571
leaq 0x230758(%rip), %rcx    # 0x3254f7
leaq 0x23064d(%rip), %r8     # 0x3253f3
movl $0x1c7, %r9d            # imm = 0x1C7
jmp 0xf4dda
movq 0x3431b3(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f0254(%rip), %rsi    # 0x2e5013
leaq 0x2307d5(%rip), %rdx    # 0x32559b
leaq 0x23072a(%rip), %rcx    # 0x3254f7
leaq 0x23061f(%rip), %r8     # 0x3253f3
movl $0x1c8, %r9d            # imm = 0x1C8
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x34317b(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f021c(%rip), %rsi    # 0x2e5013
leaq 0x23065c(%rip), %rdx    # 0x32545a
leaq 0x2306f2(%rip), %rcx    # 0x3254f7
leaq 0x2305e7(%rip), %r8     # 0x3253f3
movl $0x1a7, %r9d            # imm = 0x1A7
jmp 0xf4dda
movq 0x34314d(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f01ee(%rip), %rsi    # 0x2e5013
leaq 0x2306e9(%rip), %rdx    # 0x325515
leaq 0x2306c4(%rip), %rcx    # 0x3254f7
leaq 0x2305b9(%rip), %r8     # 0x3253f3
movl $0x1a8, %r9d            # imm = 0x1A8
jmp 0xf4dda
movq 0x34311f(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f01c0(%rip), %rsi    # 0x2e5013
leaq 0x230717(%rip), %rdx    # 0x325571
leaq 0x230696(%rip), %rcx    # 0x3254f7
leaq 0x23058b(%rip), %r8     # 0x3253f3
movl $0x1d3, %r9d            # imm = 0x1D3
jmp 0xf4dda
movq 0x3430ee(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f018f(%rip), %rsi    # 0x2e5013
leaq 0x230710(%rip), %rdx    # 0x32559b
leaq 0x230665(%rip), %rcx    # 0x3254f7
leaq 0x23055a(%rip), %r8     # 0x3253f3
movl $0x1d4, %r9d            # imm = 0x1D4
jmp 0xf4dda
movq 0x3430bd(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f015e(%rip), %rsi    # 0x2e5013
leaq 0x230683(%rip), %rdx    # 0x32553f
leaq 0x230634(%rip), %rcx    # 0x3254f7
leaq 0x230529(%rip), %r8     # 0x3253f3
movl $0x1ac, %r9d            # imm = 0x1AC
jmp 0xf4dda