// File: /workspace/github_c_makefile_star2_O3/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 0x157b5c
movq %rcx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq 0x28(%rdi), %rcx
cmpq %rsi, %rcx
jbe 0x157b61
movq %rdx, %r12
movq (%r14), %rax
movq (%rax,%rcx,8), %rdx
cmpq 0x38(%r14), %rdx
jne 0x157adc
addq $0x64, %rdx
movq %rdx, %xmm0
punpckldq 0x1efe8b(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1efe93(%rip), %xmm0   # 0x3478f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x1f02a7(%rip), %xmm1   # 0x347d18
cvttsd2si %xmm1, %rax
movq %rax, %rcx
subsd 0x1f029f(%rip), %xmm1   # 0x347d20
sarq $0x3f, %rcx
cvttsd2si %xmm1, %rsi
andq %rcx, %rsi
orq %rax, %rsi
movq %rsi, 0x38(%r14)
movq 0x10(%r14), %rdi
shlq $0x3, %rsi
leaq 0x22d53d(%rip), %r13    # 0x384fe0
movq %r13, %rdx
movl $0x1e9, %ecx            # imm = 0x1E9
callq 0x104461
movq %rax, 0x10(%r14)
movq 0x18(%r14), %rdi
movq 0x38(%r14), %rsi
shlq $0x3, %rsi
movq %r13, %rdx
movl $0x1eb, %ecx            # imm = 0x1EB
callq 0x104461
movq %rax, 0x18(%r14)
movq (%r14), %rax
movq 0x28(%r14), %rcx
movq (%rax,%rcx,8), %rdx
movq (%rax,%rbx,8), %rsi
movq 0x8(%rax,%rbx,8), %rcx
incq %rsi
cmpq %rcx, %rdx
jbe 0x157b13
movq 0x10(%r14), %rdi
movq 0x18(%r14), %r8
movq -0x8(%rdi,%rdx,8), %r9
movq %r9, (%rdi,%rdx,8)
movq -0x8(%r8,%rdx,8), %r9
movq %r9, (%r8,%rdx,8)
leaq -0x1(%rdx), %r9
movq %r9, %rdx
cmpq %rcx, %r9
ja 0x157af5
movq 0x10(%r14), %rdx
cmpq %rcx, %rsi
jbe 0x157b22
movq 0x18(%r14), %rsi
jmp 0x157b34
cmpq %r12, -0x8(%rdx,%rcx,8)
jae 0x157b66
movq 0x18(%r14), %rsi
cmpq %r15, -0x8(%rsi,%rcx,8)
ja 0x157b6b
movq %r12, (%rdx,%rcx,8)
movq %r15, (%rsi,%rcx,8)
cmpq %rbx, 0x28(%r14)
jbe 0x157b52
incq %rbx
incq (%rax,%rbx,8)
incq %rbx
cmpq 0x28(%r14), %rbx
jbe 0x157b45
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x4a1a4
callq 0x4a0f9
callq 0x4a132
callq 0x4a16b