// File: /workspace/github_c_makefile_star2_O2/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 0xf5028
movq %rcx, %r14
movq %rsi, %r12
movq %rdi, %rbx
movq 0x28(%rdi), %rcx
cmpq %rsi, %rcx
jbe 0xf5059
movq %rdx, %r15
movq (%rbx), %rax
movq (%rax,%rcx,8), %rsi
cmpq 0x38(%rbx), %rsi
jne 0xf4fa9
addq $0x64, %rsi
movq %rsi, %xmm0
punpckldq 0x1f29be(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1f29c6(%rip), %xmm0   # 0x2e78f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x1f2dda(%rip), %xmm1   # 0x2e7d18
cvttsd2si %xmm1, %rax
movq %rax, %rcx
subsd 0x1f2dd2(%rip), %xmm1   # 0x2e7d20
sarq $0x3f, %rcx
cvttsd2si %xmm1, %rsi
andq %rcx, %rsi
orq %rax, %rsi
movq %rsi, 0x38(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x3, %rsi
leaq 0x230483(%rip), %r13    # 0x3253f3
movq %r13, %rdx
movl $0x1e9, %ecx            # imm = 0x1E9
callq 0x93472
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rdi
movq 0x38(%rbx), %rsi
shlq $0x3, %rsi
movq %r13, %rdx
movl $0x1eb, %ecx            # imm = 0x1EB
callq 0x93472
movq %rax, 0x18(%rbx)
movq (%rbx), %rax
movq 0x28(%rbx), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x1(%r12), %rcx
movq (%rax,%r12,8), %rdi
movq 0x8(%rax,%r12,8), %rdx
incq %rdi
cmpq %rdx, %rsi
jbe 0xf4fde
movq 0x10(%rbx), %r8
movq -0x8(%r8,%rsi,8), %r9
movq %r9, (%r8,%rsi,8)
movq 0x18(%rbx), %r8
movq -0x8(%r8,%rsi,8), %r9
movq %r9, (%r8,%rsi,8)
decq %rsi
jmp 0xf4fba
movq 0x10(%rbx), %rsi
cmpq %rdx, %rdi
jbe 0xf4fed
movq 0x18(%rbx), %rdi
jmp 0xf5007
cmpq %r15, -0x8(%rsi,%rdx,8)
jae 0xf5087
movq 0x18(%rbx), %rdi
cmpq %r14, -0x8(%rdi,%rdx,8)
ja 0xf50b5
movq %r15, (%rsi,%rdx,8)
movq %r14, (%rdi,%rdx,8)
cmpq 0x28(%rbx), %rcx
ja 0xf501e
incq (%rax,%rcx,8)
incq %rcx
jmp 0xf500f
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x342f39(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1effda(%rip), %rsi    # 0x2e5013
leaq 0x23041a(%rip), %rdx    # 0x32545a
leaq 0x230578(%rip), %rcx    # 0x3255bf
leaq 0x2303a5(%rip), %r8     # 0x3253f3
movl $0x1e2, %r9d            # imm = 0x1E2
jmp 0xf50e1
movq 0x342f08(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1effa9(%rip), %rsi    # 0x2e5013
leaq 0x230568(%rip), %rdx    # 0x3255d9
leaq 0x230547(%rip), %rcx    # 0x3255bf
leaq 0x230374(%rip), %r8     # 0x3253f3
movl $0x1e3, %r9d            # imm = 0x1E3
jmp 0xf50e1
movq 0x342eda(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1eff7b(%rip), %rsi    # 0x2e5013
leaq 0x230558(%rip), %rdx    # 0x3255f7
leaq 0x230519(%rip), %rcx    # 0x3255bf
leaq 0x230346(%rip), %r8     # 0x3253f3
movl $0x1fa, %r9d            # imm = 0x1FA
jmp 0xf50e1
movq 0x342eac(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1eff4d(%rip), %rsi    # 0x2e5013
leaq 0x23054d(%rip), %rdx    # 0x32561a
leaq 0x2304eb(%rip), %rcx    # 0x3255bf
leaq 0x230318(%rip), %r8     # 0x3253f3
movl $0x1fb, %r9d            # imm = 0x1FB
xorl %eax, %eax
callq 0x17a50
callq 0x17390