// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/diagbandseed.c
// Function: gt_diagbandseed_processhistogram
static GtUword gt_diagbandseed_processhistogram(GtUword *histogram,
                                                GtUword maxfreq,
                                                GtUword maxgram,
                                                GtUword memlimit,
                                                GtUword mem_used,
                                                bool alist_blist_id,
                                                size_t sizeofunit)
{
  /* calculate available memory, take 98% of memlimit */
  GtUword count = 0, frequency = 0, mem_avail = 0.98 * memlimit;

  if (mem_avail > mem_used) {
    mem_avail = (mem_avail - mem_used) / sizeofunit;
  } else {
    mem_avail = 0;
    maxfreq = 0;
  }

  /* there is enough free memory */
  if (mem_avail > 0) {
    /* count seeds until available memory reached */
    for (frequency = 1; frequency <= maxgram && count < mem_avail;
         frequency++) {
      count += histogram[frequency - 1];
    }
    if (count > mem_avail) {
      gt_assert(frequency >= 2);
      frequency -= 2;
      gt_assert(count >= histogram[frequency]);
      count -= histogram[frequency];
    } else if (frequency == maxgram + 1) {
      frequency = GT_UWORD_MAX;
    }
    maxfreq = GT_MIN(maxfreq, frequency);
  }

  /* determine minimum required memory for error message */
  if (maxfreq <= 1 && alist_blist_id) {
    count = (histogram[0] + histogram[1]) * sizeofunit;
    count = (count + mem_used) / 0.98;
  } else if (maxfreq == 0) {
    count = histogram[0] * sizeofunit;
    count = (count + mem_used) / 0.98;
  }
  histogram[maxgram] = count;
  return maxfreq;
}

// Assembly:
subq $0x58, %rsp
movb %r9b, %al
movq 0x60(%rsp), %r9
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x30(%rsp)
andb $0x1, %al
movb %al, 0x2f(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movaps 0x2ff41c(%rip), %xmm1   # 0x518930
movq 0x38(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2ff41a(%rip), %xmm1   # 0x518940
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x3589bb(%rip), %xmm1   # 0x571ef8
mulsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x2ff818(%rip), %xmm1   # 0x518d70
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq 0x30(%rsp), %rax
jbe 0x219592
movq 0x10(%rsp), %rax
subq 0x30(%rsp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq 0x60(%rsp)
movq %rax, 0x10(%rsp)
jmp 0x2195a4
movq $0x0, 0x10(%rsp)
movq $0x0, 0x48(%rsp)
cmpq $0x0, 0x10(%rsp)
jbe 0x219727
movq $0x1, 0x18(%rsp)
movq 0x18(%rsp), %rcx
xorl %eax, %eax
cmpq 0x40(%rsp), %rcx
movb %al, 0xf(%rsp)
ja 0x2195dc
movq 0x20(%rsp), %rax
cmpq 0x10(%rsp), %rax
setb %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x2195e6
jmp 0x219612
movq 0x50(%rsp), %rax
movq 0x18(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
addq 0x20(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x2195b9
movq 0x20(%rsp), %rax
cmpq 0x10(%rsp), %rax
jbe 0x2196e0
jmp 0x219624
cmpq $0x2, 0x18(%rsp)
jae 0x219664
movq 0x42296d(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2fc9d6(%rip), %rsi    # 0x516013
leaq 0x359ad1(%rip), %rdx    # 0x573115
leaq 0x359ad9(%rip), %rcx    # 0x573124
leaq 0x358942(%rip), %r8     # 0x571f94
movl $0x4cd, %r9d            # imm = 0x4CD
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x219666
movq 0x18(%rsp), %rax
subq $0x2, %rax
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq 0x50(%rsp), %rcx
movq 0x18(%rsp), %rdx
cmpq (%rcx,%rdx,8), %rax
jae 0x2196c1
movq 0x422910(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2fc979(%rip), %rsi    # 0x516013
leaq 0x359aa4(%rip), %rdx    # 0x573145
leaq 0x359a7c(%rip), %rcx    # 0x573124
leaq 0x3588e5(%rip), %r8     # 0x571f94
movl $0x4cf, %r9d            # imm = 0x4CF
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2196c3
movq 0x50(%rsp), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq 0x20(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x20(%rsp)
jmp 0x2196fe
movq 0x18(%rsp), %rax
movq 0x40(%rsp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jne 0x2196fc
movq $-0x1, 0x18(%rsp)
jmp 0x2196fe
movq 0x48(%rsp), %rax
cmpq 0x18(%rsp), %rax
jae 0x219715
movq 0x48(%rsp), %rax
movq %rax, (%rsp)
jmp 0x21971e
movq 0x18(%rsp), %rax
movq %rax, (%rsp)
movq (%rsp), %rax
movq %rax, 0x48(%rsp)
cmpq $0x1, 0x48(%rsp)
ja 0x2197cb
testb $0x1, 0x2f(%rsp)
je 0x2197cb
movq 0x50(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
addq %rcx, %rax
movq 0x60(%rsp), %rcx
imulq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
addq %rcx, %rax
movq %rax, %xmm0
movaps 0x2ff1bc(%rip), %xmm1   # 0x518930
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2ff1c0(%rip), %xmm1   # 0x518940
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x358761(%rip), %xmm1   # 0x571ef8
divsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x2ff5be(%rip), %xmm1   # 0x518d70
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x20(%rsp)
jmp 0x21985a
cmpq $0x0, 0x48(%rsp)
jne 0x219858
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x60(%rsp), %rcx
imulq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
addq %rcx, %rax
movq %rax, %xmm0
movaps 0x2ff12a(%rip), %xmm1   # 0x518930
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2ff12e(%rip), %xmm1   # 0x518940
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x3586cf(%rip), %xmm1   # 0x571ef8
divsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x2ff52c(%rip), %xmm1   # 0x518d70
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x20(%rsp)
jmp 0x21985a
movq 0x20(%rsp), %rdx
movq 0x50(%rsp), %rax
movq 0x40(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x48(%rsp), %rax
addq $0x58, %rsp
retq
nopw (%rax,%rax)