// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movb $0x1, 0xf(%rsp)
cmpq $0x0, 0x40(%rsp)
jne 0x1991ed
movq 0x4a2de4(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x37ce4d(%rip), %rsi    # 0x516013
leaq 0x3be5d5(%rip), %rdx    # 0x5577a2
leaq 0x3be733(%rip), %rcx    # 0x557907
leaq 0x3be560(%rip), %r8     # 0x55773b
movl $0x1e2, %r9d            # imm = 0x1E2
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1991ef
jmp 0x1991f1
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jb 0x199239
movq 0x4a2d98(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x37ce01(%rip), %rsi    # 0x516013
leaq 0x3be708(%rip), %rdx    # 0x557921
leaq 0x3be6e7(%rip), %rcx    # 0x557907
leaq 0x3be514(%rip), %r8     # 0x55773b
movl $0x1e3, %r9d            # imm = 0x1E3
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x19923b
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x40(%rsp), %rcx
cmpq 0x38(%rcx), %rax
jne 0x199338
movq 0x40(%rsp), %rax
movq 0x38(%rax), %rcx
addq $0x64, %rcx
movq %rcx, 0x38(%rax)
movq 0x40(%rsp), %rax
movq 0x38(%rax), %xmm0
movaps 0x37f6af(%rip), %xmm1   # 0x518930
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x37f6b3(%rip), %xmm1   # 0x518940
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x37fac4(%rip), %xmm1   # 0x518d68
mulsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movq %rcx, %rsi
sarq $0x3f, %rsi
movsd 0x37fab1(%rip), %xmm1   # 0x518d70
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rdx
andq %rsi, %rdx
orq %rdx, %rcx
movq %rcx, 0x38(%rax)
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x40(%rsp), %rax
movq 0x38(%rax), %rsi
shlq $0x3, %rsi
leaq 0x3be44c(%rip), %rdx    # 0x55773b
movl $0x1e9, %ecx            # imm = 0x1E9
callq 0xe8540
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x40(%rsp), %rax
movq 0x38(%rax), %rsi
shlq $0x3, %rsi
leaq 0x3be419(%rip), %rdx    # 0x55773b
movl $0x1eb, %ecx            # imm = 0x1EB
callq 0xe8540
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x20(%rsp)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
addq $0x1, %rax
cmpq 0x18(%rsp), %rax
jbe 0x19937a
movb $0x0, 0xf(%rsp)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq 0x18(%rsp), %rax
jbe 0x199400
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rdx
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rdx
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0x199394
testb $0x1, 0xf(%rsp)
je 0x1994bf
jmp 0x19940d
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
cmpq 0x30(%rsp), %rax
jb 0x199462
movq 0x4a2b6f(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x37cbd8(%rip), %rsi    # 0x516013
leaq 0x3be4fd(%rip), %rdx    # 0x55793f
leaq 0x3be4be(%rip), %rcx    # 0x557907
leaq 0x3be2eb(%rip), %r8     # 0x55773b
movl $0x1fa, %r9d            # imm = 0x1FA
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x199464
jmp 0x199466
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
cmpq 0x28(%rsp), %rax
jbe 0x1994bb
movq 0x4a2b16(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x37cb7f(%rip), %rsi    # 0x516013
leaq 0x3be4c7(%rip), %rdx    # 0x557962
leaq 0x3be465(%rip), %rcx    # 0x557907
leaq 0x3be292(%rip), %r8     # 0x55773b
movl $0x1fb, %r9d            # imm = 0x1FB
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1994bd
jmp 0x1994bf
movq 0x30(%rsp), %rdx
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x28(%rsp), %rdx
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq 0x40(%rsp), %rcx
cmpq 0x28(%rcx), %rax
ja 0x199534
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0x1994fb
addq $0x48, %rsp
retq
nopl (%rax)