// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/kmer_database.c
// Function: gt_kmer_database_add_kmer
void gt_kmer_database_add_kmer(GtKmerDatabase *kdb,
                               GtCodetype kmercode,
                               GtUword startpos,
                               GtUword id)
{
  GtUword start,
          end,
          i;
  bool    in_db = true;

  gt_assert(kdb != NULL);
  gt_assert(kmercode < kdb->nu_kmer_codes);

  if (kdb->offset[kdb->nu_kmer_codes] == kdb->current_size) {
    kdb->current_size += 100;
    kdb->current_size *= 1.2;
    kdb->positions = gt_realloc((void*) kdb->positions, (size_t)
                                kdb->current_size * sizeof (*kdb->positions));
    kdb->unique_ids = gt_realloc((void*) kdb->unique_ids, (size_t)
                                 kdb->current_size * sizeof (*kdb->unique_ids));
  }

  start = kdb->offset[kmercode];
  end = kdb->offset[kmercode + 1];

  if (start + 1 > end)
    in_db = false;

  for (i = kdb->offset[kdb->nu_kmer_codes]; i > end; i--) {
    kdb->positions[i] = kdb->positions[i - 1];
    kdb->unique_ids[i] = kdb->unique_ids[i - 1];
  }

  if (in_db) {
    gt_assert(kdb->positions[end - 1] < startpos);
    gt_assert(kdb->unique_ids[end - 1] <= id);
  }

  kdb->positions[end] = startpos;
  kdb->unique_ids[end] = id;

  for (i = kmercode + 1; i <= kdb->nu_kmer_codes; i++)
    kdb->offset[i]++;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x15f75a
movq %rsi, %rbx
movq %rdi, %r14
movq 0x28(%rdi), %rax
cmpq %rsi, %rax
jbe 0x15f75f
movq %rcx, %r15
movq %rdx, %r12
movq (%r14), %rdx
movq 0x38(%r14), %rcx
cmpq %rcx, (%rdx,%rax,8)
jne 0x15f6d1
addq $0x64, %rcx
movq %rcx, %xmm0
punpckldq 0x1f128b(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1f1293(%rip), %xmm0   # 0x3508f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x1f16a7(%rip), %xmm1   # 0x350d18
cvttsd2si %xmm1, %rax
movq %rax, %rcx
subsd 0x1f169f(%rip), %xmm1   # 0x350d20
sarq $0x3f, %rcx
cvttsd2si %xmm1, %rsi
andq %rcx, %rsi
orq %rax, %rsi
movq %rsi, 0x38(%r14)
movq 0x10(%r14), %rdi
shlq $0x3, %rsi
leaq 0x22ed15(%rip), %r13    # 0x38e3b8
movq %r13, %rdx
movl $0x1e9, %ecx            # imm = 0x1E9
callq 0x1094e6
movq %rax, 0x10(%r14)
movq 0x18(%r14), %rdi
movq 0x38(%r14), %rsi
shlq $0x3, %rsi
movq %r13, %rdx
movl $0x1eb, %ecx            # imm = 0x1EB
callq 0x1094e6
movq %rax, 0x18(%r14)
movq (%r14), %rax
movq 0x28(%r14), %rsi
movq (%rax,%rbx,8), %rdx
movq 0x8(%rax,%rbx,8), %rcx
incq %rdx
movq (%rax,%rsi,8), %rsi
cmpq %rcx, %rsi
jbe 0x15f713
movq 0x10(%r14), %rdi
movq 0x18(%r14), %r8
movq -0x8(%rdi,%rsi,8), %r9
movq %r9, (%rdi,%rsi,8)
movq -0x8(%r8,%rsi,8), %r9
movq %r9, (%r8,%rsi,8)
leaq -0x1(%rsi), %r9
movq %r9, %rsi
cmpq %rcx, %r9
ja 0x15f6f5
cmpq %rcx, %rdx
ja 0x15f72e
movq 0x10(%r14), %rdx
cmpq %r12, -0x8(%rdx,%rcx,8)
jae 0x15f764
movq 0x18(%r14), %rdx
cmpq %r15, -0x8(%rdx,%rcx,8)
ja 0x15f769
incq %rbx
movq 0x10(%r14), %rdx
movq %r12, (%rdx,%rcx,8)
movq 0x18(%r14), %rdx
movq %r15, (%rdx,%rcx,8)
cmpq 0x28(%r14), %rbx
ja 0x15f750
incq (%rax,%rbx,8)
incq %rbx
jmp 0x15f741
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x4afb7
callq 0x4af0c
callq 0x4af45
callq 0x4af7e