// File: /workspace/github_c_makefile_star2_O3/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, 0x10(%rsp)
movq %r8, 0x20(%rsp)
movq %rcx, %rbx
movq %rdx, %rbp
movq %rdi, 0x18(%rsp)
movq 0x88(%rsp), %rcx
movq %rsi, %r12
movq (%rsi), %r14
leaq 0x1(%r14), %rax
cmpq $0x1ffe, %r14           # imm = 0x1FFE
movl $0x1fff, %r15d          # imm = 0x1FFF
cmovbq %rax, %r15
cmpb $0x0, 0x80(%rsp)
je 0x1949ef
leaq 0x20bc1b(%rip), %rdi    # 0x3a05e7
movl $0x31, %esi
movl $0x1, %edx
callq 0x17fa0
callq 0x11c954
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x11c9e3
jmp 0x1949f8
movq $0x0, 0x8(%rsp)
leaq 0x1(%r15), %rdi
leaq 0x20b1d9(%rip), %rdx    # 0x39fbdc
movl $0x8, %esi
movl $0x876, %ecx            # imm = 0x876
callq 0x10436a
movq %rax, %r13
movq (%r12), %r9
subq $0x8, %rsp
movzbl 0x78(%rsp), %eax
xorl %edi, %edi
movq %r13, %rsi
xorl %edx, %edx
movq %rbp, %rcx
movq %rbx, %r8
pushq %rax
pushq 0x70(%rsp)
pushq %r15
callq 0x196c8b
addq $0x20, %rsp
movsd 0x20(%rsp), %xmm0
unpcklps 0x1b2e94(%rip), %xmm0   # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b2e9c(%rip), %xmm0   # 0x3478f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x20b0a8(%rip), %xmm1   # 0x39fb10
movq 0x68(%rsp), %rbx
shlq $0x4, %rbx
cvttsd2si %xmm1, %rax
movq %rax, %rdx
subsd 0x1b329f(%rip), %xmm1   # 0x347d20
cvttsd2si %xmm1, %rcx
sarq $0x3f, %rdx
andq %rdx, %rcx
orq %rax, %rcx
subq %rbx, %rcx
jbe 0x194af6
movb 0x78(%rsp), %r10b
movq (%r12), %rsi
xorl %edi, %edi
movq %rcx, %rax
xorl %edx, %edx
movq 0x10(%rsp), %r11
divq %r11
cmpq %r11, %rcx
movq %r12, %rbp
jb 0x194b29
movq $-0x1, %rcx
xorl %edx, %edx
movq %rdx, %rdi
leaq 0x2(%rcx), %r9
movq 0x8(%r13,%rcx,8), %r8
addq %r8, %rdx
incq %rcx
cmpq %r15, %r9
jae 0x194ada
cmpq %rax, %rdx
jb 0x194abe
movl $0x1ffe, %r9d           # imm = 0x1FFE
cmpq %r9, %r14
cmovbq %r14, %r9
cmpq %rax, %rdx
jbe 0x194b0d
cmpq %r8, %rdx
jae 0x194b22
callq 0x5d39e
cmpb $0x0, 0x78(%rsp)
movq %r12, %rbp
movq 0x10(%rsp), %r11
je 0x194b93
xorl %esi, %esi
jmp 0x194b35
leaq 0x2(%rcx), %rax
cmpq %rcx, %r9
movq $-0x1, %rcx
cmovneq %rax, %rcx
movq %rdx, %rdi
cmpq %rcx, %rsi
cmovaeq %rcx, %rsi
cmpq $0x2, %rsi
setb %al
testb %r10b, %al
je 0x194b8e
movq 0x8(%r13), %rax
addq (%r13), %rax
imulq %r11, %rax
addq %rbx, %rax
movq %rax, %xmm0
punpckldq 0x1b2d8f(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b2d97(%rip), %xmm0   # 0x3478f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0x20afa3(%rip), %xmm1   # 0x39fb10
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x1b319f(%rip), %xmm1   # 0x347d20
cvttsd2si %xmm1, %rdi
andq %rcx, %rdi
orq %rax, %rdi
jmp 0x194be5
testq %rsi, %rsi
jne 0x194be5
imulq (%r13), %r11
addq %rbx, %r11
movq %r11, %xmm0
punpckldq 0x1b2d38(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b2d40(%rip), %xmm0   # 0x3478f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0x20af4c(%rip), %xmm1   # 0x39fb10
cvttsd2si %xmm1, %rax
movq %rax, %rcx
subsd 0x1b314c(%rip), %xmm1   # 0x347d20
cvttsd2si %xmm1, %rdi
sarq $0x3f, %rcx
andq %rcx, %rdi
orq %rax, %rdi
xorl %esi, %esi
movq %rdi, (%r13,%r15,8)
movq %rbp, %r12
movq %rsi, (%rbp)
movq (%r13,%r15,8), %rax
movq 0x18(%rsp), %rbx
movq %rax, (%rbx)
leaq 0x20afd7(%rip), %rsi    # 0x39fbdc
movq %r13, %rdi
movl $0x889, %edx            # imm = 0x889
callq 0x1045eb
movb 0x80(%rsp), %bpl
testb %bpl, %bpl
movq 0x88(%rsp), %r14
je 0x194c46
leaq 0x20b9eb(%rip), %rsi    # 0x3a0619
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0x11ca64
movq %r15, %rdi
callq 0x11d054
movq (%r12), %rdx
testq %rdx, %rdx
je 0x194c5c
cmpq $0x1, %rdx
jne 0x194c8a
cmpb $0x0, 0x78(%rsp)
je 0x194cb0
movq 0x90(%rsp), %rdi
movq (%rbx), %rdx
shrq $0x14, %rdx
incq %rdx
leaq 0x20b9d4(%rip), %rsi    # 0x3a0649
xorl %eax, %eax
callq 0xfcb67
movq $0x0, (%rbx)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x194cf9
testb %bpl, %bpl
je 0x194cde
cmpq $-0x1, %rdx
jne 0x194cb5
leaq 0x20b9de(%rip), %rdi    # 0x3a067a
movl $0x23, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x17fa0
jmp 0x194cc6
testb %bpl, %bpl
je 0x194ce6
leaq 0x20b9e2(%rip), %rsi    # 0x3a069e
movq %r14, %rdi
xorl %eax, %eax
callq 0x17ab0
movq (%rbx), %rdx
leaq 0x20b9f5(%rip), %rsi    # 0x3a06c5
xorl %ebx, %ebx
movq %r14, %rdi
xorl %eax, %eax
callq 0x17ab0
jmp 0x194cf9
xorl %ebx, %ebx
cmpq $0x5, %rdx
ja 0x194cf9
leaq 0x20b9eb(%rip), %rdi    # 0x3a06d8
xorl %ebx, %ebx
movq %rdx, %rsi
xorl %eax, %eax
callq 0x11f68c
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq