// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/diagbandseed.c
// Function: gt_diagbandseed_get_mlistlen_maxfreq
static int gt_diagbandseed_get_mlistlen_maxfreq(GtUword *mlistlen,
                                            GtUword *maxfreq,
                                            GtDiagbandseedKmerIterator *aiter,
                                            GtDiagbandseedKmerIterator *biter,
                                            GtUword memlimit,
                                            size_t sizeofunit,
                                            const GtRange *seedpairdistance,
                                            GtUword len_used,
                                            bool selfcomp,
                                            bool alist_blist_id,
                                            bool verbose,
                                            FILE *stream,
                                            GtError *err)
{
  const GtUword maxgram = GT_MIN(*maxfreq, 8190) + 1; /* Cap on k-mer count */
  GtUword *histogram = NULL;
  GtTimer *timer = NULL;
  int had_err = 0;

  gt_assert(memlimit < GT_UWORD_MAX);
  if (verbose) {
    fprintf(stream, "# start calculating k-mer frequency histogram...\n");
    timer = gt_timer_new();
    gt_timer_start(timer);
  }

  /* build histogram; histogram[maxgram] := estimation for mlistlen */
  histogram = gt_calloc(maxgram + 1, sizeof *histogram);
  gt_diagbandseed_merge(NULL, /* mlist not needed: just count */
                        histogram,
                        false,
                        aiter,
                        biter,
                        *maxfreq,
                        maxgram,
                        seedpairdistance,
                        selfcomp);
  *maxfreq = gt_diagbandseed_processhistogram(histogram,
                                              *maxfreq,
                                              maxgram,
                                              memlimit,
                                              len_used *
                                                sizeof (GtDiagbandseedKmerPos),
                                              alist_blist_id,
                                              sizeofunit);
  *mlistlen = histogram[maxgram];
  gt_free(histogram);

  if (verbose) {
    gt_timer_show_formatted(timer,"# ... finished histogram "
                            GT_DIAGBANDSEED_FMT,stream);
    gt_timer_delete(timer);
  }

  /* check maxfreq value */
  if (*maxfreq == 0 || (*maxfreq == 1 && alist_blist_id)) {
    gt_error_set(err,
                 "option -memlimit too strict: need at least " GT_WU "MB",
                 (*mlistlen >> 20) + 1);
    *mlistlen = 0;
    had_err = -1;
  } else if (verbose) {
    if (*maxfreq == GT_UWORD_MAX) {
      fprintf(stream, "# disable k-mer maximum frequency, ");
    } else {
      fprintf(stream, "# set k-mer maximum frequency to " GT_WU ", ", *maxfreq);
    }
    fprintf(stream, "expect " GT_WU " seeds.\n", *mlistlen);
  } else if (*maxfreq <= 5) {
    gt_warning("only k-mers occurring <= " GT_WU " times will be considered, "
               "due to small memlimit.", *maxfreq);
  }

  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movq %rcx, %rbx
movq %rdx, %r12
movq %rdi, 0x10(%rsp)
movq 0x88(%rsp), %rcx
movq %rsi, %r14
movq (%rsi), %r15
leaq 0x1(%r15), %rax
cmpq $0x1ffe, %r15           # imm = 0x1FFE
movl $0x1fff, %r13d          # imm = 0x1FFF
cmovbq %rax, %r13
cmpb $0x0, 0x80(%rsp)
je 0x19cfe7
leaq 0x20cba3(%rip), %rdi    # 0x3a9b67
movl $0x31, %esi
movl $0x1, %edx
callq 0x17fa0
callq 0x1226a4
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x122733
jmp 0x19cff0
movq $0x0, 0x8(%rsp)
leaq 0x1(%r13), %rdi
leaq 0x20c0d1(%rip), %rdx    # 0x3a90cc
movl $0x8, %esi
movl $0x876, %ecx            # imm = 0x876
callq 0x1093ef
movq %rax, %rbp
movq %r14, %r8
movq (%r14), %r9
subq $0x8, %rsp
movzbl 0x78(%rsp), %eax
xorl %r14d, %r14d
xorl %edi, %edi
movq %rbp, %rsi
xorl %edx, %edx
movq %r12, %rcx
movq %r8, %r12
movq %rbx, %r8
pushq %rax
pushq 0x70(%rsp)
pushq %r13
callq 0x19f0f2
addq $0x20, %rsp
movsd 0x18(%rsp), %xmm0
unpcklps 0x1b3894(%rip), %xmm0   # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movq 0x68(%rsp), %r8
shlq $0x4, %r8
subpd 0x1b3893(%rip), %xmm0   # 0x3508f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x20bf8f(%rip), %xmm1   # 0x3a9000
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
subsd 0x1b3c9b(%rip), %xmm1   # 0x350d20
cvttsd2si %xmm1, %rcx
andq %rdx, %rcx
orq %rax, %rcx
movl $0x0, %eax
subq %r8, %rcx
movq 0x20(%rsp), %rdi
jbe 0x19d0ab
movq (%r12), %r14
movq %rcx, %rax
xorl %edx, %edx
divq %rdi
testq %rax, %rax
je 0x19d0ec
movq $-0x1, %rdx
xorl %ecx, %ecx
leaq 0x2(%rdx), %rsi
addq 0x8(%rbp,%rdx,8), %rcx
incq %rdx
cmpq %r13, %rsi
jae 0x19d0cf
cmpq %rax, %rcx
jb 0x19d0b9
movl $0x1ffe, %esi           # imm = 0x1FFE
cmpq %rsi, %r15
cmovbq %r15, %rsi
cmpq %rax, %rcx
jbe 0x19d0f0
subq (%rbp,%rdx,8), %rcx
jae 0x19d102
callq 0x5e7d9
xorl %ecx, %ecx
jmp 0x19d109
leaq 0x2(%rdx), %rax
cmpq %rdx, %rsi
movq $-0x1, %rdx
cmovneq %rax, %rdx
cmpq %rdx, %r14
cmovaeq %rdx, %r14
movb 0x78(%rsp), %bl
cmpq $0x2, %r14
setae %al
movl %ebx, %edx
xorb $0x1, %dl
orb %al, %dl
jne 0x19d133
movq 0x8(%rbp), %rax
addq (%rbp), %rax
imulq %rdi, %rax
addq %r8, %rax
movq %rax, %xmm0
jmp 0x19d145
testq %r14, %r14
jne 0x19d188
imulq (%rbp), %rdi
addq %r8, %rdi
movq %rdi, %xmm0
punpckldq 0x1b3793(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b379b(%rip), %xmm0   # 0x3508f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0x20be97(%rip), %xmm1   # 0x3a9000
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
subsd 0x1b3ba3(%rip), %xmm1   # 0x350d20
cvttsd2si %xmm1, %rcx
andq %rdx, %rcx
orq %rax, %rcx
movq %rcx, (%rbp,%r13,8)
movq %r14, (%r12)
movq (%rbp,%r13,8), %rax
movq 0x10(%rsp), %r14
movq %rax, (%r14)
leaq 0x20bf27(%rip), %rsi    # 0x3a90cc
movq %rbp, %rdi
movl $0x889, %edx            # imm = 0x889
callq 0x109670
movb 0x80(%rsp), %bpl
testb %bpl, %bpl
movq 0x88(%rsp), %r15
je 0x19d1e6
leaq 0x20c9cb(%rip), %rsi    # 0x3a9b99
movq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r15, %rdx
callq 0x1227b4
movq %r13, %rdi
callq 0x122d79
movq (%r12), %rdx
testq %rdx, %rdx
je 0x19d1f9
cmpq $0x1, %rdx
jne 0x19d227
testb %bl, %bl
je 0x19d227
movq 0x90(%rsp), %rdi
movq (%r14), %rdx
shrq $0x14, %rdx
incq %rdx
leaq 0x20c9b7(%rip), %rsi    # 0x3a9bc9
xorl %eax, %eax
callq 0x1019cf
movq $0x0, (%r14)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x19d291
testb %bpl, %bpl
je 0x19d245
cmpq $-0x1, %rdx
je 0x19d262
leaq 0x20c9e5(%rip), %rsi    # 0x3a9c1e
movq %r15, %rdi
xorl %eax, %eax
callq 0x17ab0
jmp 0x19d27b
xorl %ebx, %ebx
cmpq $0x5, %rdx
ja 0x19d291
leaq 0x20ca04(%rip), %rdi    # 0x3a9c58
xorl %ebx, %ebx
movq %rdx, %rsi
xorl %eax, %eax
callq 0x125448
jmp 0x19d291
leaq 0x20c991(%rip), %rdi    # 0x3a9bfa
movl $0x23, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x17fa0
movq (%r14), %rdx
leaq 0x20c9c0(%rip), %rsi    # 0x3a9c45
xorl %ebx, %ebx
movq %r15, %rdi
xorl %eax, %eax
callq 0x17ab0
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq