// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/test-maxpairs.c
// Function: gt_testmaxpairs
int gt_testmaxpairs(const char *indexname,
                    GtUword samples,
                    unsigned int minlength,
                    GtUword substringlength,
                    GtLogger *logger,
                    GtError *err)
{
  bool haserr = false;
  GtEncseq *encseq;
  GtUword idx, totallength = 0, dblen, querylen;
  GtUchar *dbseq = NULL, *query = NULL;
  GtAlphabet *alphabet = NULL;
  GtArray *tabmaxquerymatches;
  GtMaxmatchselfinfo maxmatchselfinfo;
  GtEncseqLoader *el;

  gt_logger_log(logger,"draw "GT_WU" samples",samples);
  el = gt_encseq_loader_new();
  gt_encseq_loader_do_not_require_des_tab(el);
  gt_encseq_loader_do_not_require_ssp_tab(el);
  gt_encseq_loader_do_not_require_sds_tab(el);
  gt_encseq_loader_set_logger(el, logger);
  encseq = gt_encseq_loader_load(el, indexname, err);
  gt_encseq_loader_delete(el);

  if (encseq == NULL)
  {
    haserr = true;
  } else
  {
    totallength = gt_encseq_total_length(encseq);
  }
  if (!haserr)
  {
    if (substringlength > totallength/2)
    {
      substringlength = totallength/2;
    }
    /* use one memory area for dbseq and query, since in one method
       we concatenate both sequences */
    dbseq = gt_malloc(sizeof *dbseq * (1 + GT_MULT2(substringlength)));
    alphabet = gt_encseq_alphabet(encseq);
  }
  for (idx = 0; idx < samples && !haserr; idx++)
  {
    dblen = gt_samplesubstring(false,dbseq,encseq,substringlength);
    gt_assert(dbseq != NULL);
    query = dbseq + dblen + 1;
    gt_assert(query != NULL);
    dbseq[dblen] = GT_SEPARATOR;
    querylen = gt_samplesubstring(true,query,encseq,substringlength);
    if (querylen < (GtUword) minlength || dblen < (GtUword) minlength ||
        dbseq[0] == GT_SEPARATOR || query[0] == GT_SEPARATOR ||
        dbseq[substringlength-1] == GT_SEPARATOR ||
        query[substringlength-1] == GT_SEPARATOR)
    {
      continue;
    }
    gt_logger_log(logger,"run query match for dblen="GT_WU""
                         ",querylen= "GT_WU", minlength=%u",
                         dblen,
                         querylen,
                         minlength);
    tabmaxquerymatches = gt_array_new(sizeof (Substringmatch));
    if (gt_sarrquerysubstringmatch(dbseq,
                                   dblen,
                                   query,
                                   querylen,
                                   minlength,
                                   alphabet,
                                   gt_storemaxmatchquery,
                                   tabmaxquerymatches,
                                   logger,
                                   err) != 0)
    {
      haserr = true;
      break;
    }
    gt_logger_log(logger,"run self match for dblen="GT_WU""
                         ",querylen= "GT_WU", minlength=%u",
                         dblen,
                         querylen,
                         minlength);
    maxmatchselfinfo.results = gt_array_new(sizeof (Substringmatch));
    maxmatchselfinfo.dblen = dblen;
    maxmatchselfinfo.querylen = querylen;
    maxmatchselfinfo.querymarkpos
      = gt_sequence2markpositions(&maxmatchselfinfo.numofquerysequences,
                                  query,querylen);
    if (gt_constructsarrandrunmaxpairs(
                 dbseq,
                 dblen + 1 + querylen,
                 GT_READMODE_FORWARD,
                 minlength,
                 gt_encseq_alphabetnumofchars(encseq),
                 gt_storemaxmatchself,
                 &maxmatchselfinfo,
                 err) != 0)
    {
      haserr = true;
      break;
    }
    gt_array_sort(tabmaxquerymatches,gt_orderSubstringmatch);
    gt_array_sort(maxmatchselfinfo.results,gt_orderSubstringmatch);
    if (!gt_array_equal(tabmaxquerymatches,maxmatchselfinfo.results,
                        gt_orderSubstringmatch))
    {
      const GtUword width = 60UL;
      fprintf(stderr,"failure for query of length "GT_WU"\n",querylen);
      fprintf(stderr,"querymatches\n");
      (void) gt_array_iterate(tabmaxquerymatches,gt_showSubstringmatch,NULL,
                              err);
      fprintf(stderr,"dbmatches\n");
      (void) gt_array_iterate(maxmatchselfinfo.results,gt_showSubstringmatch,
                              NULL,err);
      gt_symbolstring2fasta(stderr,"dbseq", alphabet, dbseq, dblen, width);
      gt_symbolstring2fasta(stderr,"queryseq", alphabet, query, querylen,width);
      exit(GT_EXIT_PROGRAMMING_ERROR);
    }
    gt_free(maxmatchselfinfo.querymarkpos);
    gt_array_delete(tabmaxquerymatches);
    gt_array_delete(maxmatchselfinfo.results);
  }
  gt_free(dbseq);
  gt_encseq_delete(encseq);
  return haserr ? -1 : 0;
}

// Assembly:
pushq %rbx
subq $0xf0, %rsp
movq %rdi, 0xe8(%rsp)
movq %rsi, 0xe0(%rsp)
movl %edx, 0xdc(%rsp)
movq %rcx, 0xd0(%rsp)
movq %r8, 0xc8(%rsp)
movq %r9, 0xc0(%rsp)
movb $0x0, 0xbf(%rsp)
movq $0x0, 0xa0(%rsp)
movq $0x0, 0x88(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x0, 0x78(%rsp)
movq 0xc8(%rsp), %rdi
movq 0xe0(%rsp), %rdx
leaq 0x29dd99(%rip), %rsi    # 0x58f49c
movb $0x0, %al
callq 0xe7cd0
callq 0xb7a40
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
callq 0xba820
movq 0x40(%rsp), %rdi
callq 0xba910
movq 0x40(%rsp), %rdi
callq 0xbaa10
movq 0x40(%rsp), %rdi
movq 0xc8(%rsp), %rsi
callq 0xbacf0
movq 0x40(%rsp), %rdi
movq 0xe8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
callq 0xb7aa0
movq %rax, 0xb0(%rsp)
movq 0x40(%rsp), %rdi
callq 0xb7e50
cmpq $0x0, 0xb0(%rsp)
jne 0x2f1785
movb $0x1, 0xbf(%rsp)
jmp 0x2f179a
movq 0xb0(%rsp), %rdi
callq 0xa9d00
movq %rax, 0xa0(%rsp)
testb $0x1, 0xbf(%rsp)
jne 0x2f180d
movq 0xd0(%rsp), %rax
movq 0xa0(%rsp), %rcx
shrq %rcx
cmpq %rcx, %rax
jbe 0x2f17cf
movq 0xa0(%rsp), %rax
shrq %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rdi
shlq %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
leaq 0x29dcc4(%rip), %rsi    # 0x58f4ad
movl $0x136, %edx            # imm = 0x136
callq 0xe80f0
movq %rax, 0x88(%rsp)
movq 0xb0(%rsp), %rdi
callq 0xb0f00
movq %rax, 0x78(%rsp)
movq $0x0, 0xa8(%rsp)
movq 0xa8(%rsp), %rcx
xorl %eax, %eax
cmpq 0xe0(%rsp), %rcx
movb %al, 0x37(%rsp)
jae 0x2f183e
movb 0xbf(%rsp), %al
xorb $-0x1, %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x2f184b
jmp 0x2f1d16
movq 0x88(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0xd0(%rsp), %rcx
xorl %edi, %edi
callq 0x2f1d60
movq %rax, 0x98(%rsp)
cmpq $0x0, 0x88(%rsp)
jne 0x2f18b5
movq 0x34a71c(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x224785(%rip), %rsi    # 0x516013
leaq 0x29dc32(%rip), %rdx    # 0x58f4c7
leaq 0x29dc39(%rip), %rcx    # 0x58f4d5
leaq 0x29dc0a(%rip), %r8     # 0x58f4ad
movl $0x13c, %r9d            # imm = 0x13C
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2f18b7
movq 0x88(%rsp), %rax
addq 0x98(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x80(%rsp)
cmpq $0x0, 0x80(%rsp)
jne 0x2f1916
movq 0x34a6bb(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x224724(%rip), %rsi    # 0x516013
leaq 0x29dbef(%rip), %rdx    # 0x58f4e5
leaq 0x29dbd8(%rip), %rcx    # 0x58f4d5
leaq 0x29dba9(%rip), %r8     # 0x58f4ad
movl $0x13e, %r9d            # imm = 0x13E
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2f1918
movq 0x88(%rsp), %rax
movq 0x98(%rsp), %rcx
movb $-0x1, (%rax,%rcx)
movq 0x80(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0xd0(%rsp), %rcx
movl $0x1, %edi
callq 0x2f1d60
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rax
movl 0xdc(%rsp), %ecx
cmpq %rcx, %rax
jb 0x2f19e0
movq 0x98(%rsp), %rax
movl 0xdc(%rsp), %ecx
cmpq %rcx, %rax
jb 0x2f19e0
movq 0x88(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xff, %eax
je 0x2f19e0
movq 0x80(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xff, %eax
je 0x2f19e0
movq 0x88(%rsp), %rax
movq 0xd0(%rsp), %rcx
subq $0x1, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
je 0x2f19e0
movq 0x80(%rsp), %rax
movq 0xd0(%rsp), %rcx
subq $0x1, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
jne 0x2f19e5
jmp 0x2f1cfd
movq 0xc8(%rsp), %rdi
movq 0x98(%rsp), %rdx
movq 0x90(%rsp), %rcx
movl 0xdc(%rsp), %r8d
leaq 0x29dae7(%rip), %rsi    # 0x58f4f3
movb $0x0, %al
callq 0xe7cd0
movl $0x20, %edi
callq 0x80990
movq %rax, 0x70(%rsp)
movq 0x88(%rsp), %rdi
movq 0x98(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq 0x90(%rsp), %rcx
movl 0xdc(%rsp), %r8d
movq 0x78(%rsp), %r9
movq 0x70(%rsp), %r11
movq 0xc8(%rsp), %r10
movq 0xc0(%rsp), %rax
leaq 0x445(%rip), %rbx       # 0x2f1eb0
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x2388e0
cmpl $0x0, %eax
je 0x2f1a95
movb $0x1, 0xbf(%rsp)
jmp 0x2f1d16
movq 0xc8(%rsp), %rdi
movq 0x98(%rsp), %rdx
movq 0x90(%rsp), %rcx
movl 0xdc(%rsp), %r8d
leaq 0x29da71(%rip), %rsi    # 0x58f52d
movb $0x0, %al
callq 0xe7cd0
movl $0x20, %edi
callq 0x80990
movq %rax, 0x48(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x48(%rsp), %rdi
addq $0x20, %rdi
movq 0x80(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0x2f1f30
movq %rax, 0x58(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x98(%rsp), %rax
addq $0x1, %rax
addq 0x90(%rsp), %rax
movq %rax, 0x28(%rsp)
movl 0xdc(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0xb0(%rsp), %rdi
callq 0xb0e80
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x30(%rsp), %ecx
movl %eax, %r8d
movq 0xc0(%rsp), %rax
xorl %edx, %edx
leaq 0x5a1(%rip), %r9        # 0x2f2110
leaq 0x48(%rsp), %r10
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x2f2060
cmpl $0x0, %eax
je 0x2f1b94
movb $0x1, 0xbf(%rsp)
jmp 0x2f1d16
movq 0x70(%rsp), %rdi
leaq 0x710(%rip), %rsi       # 0x2f22b0
callq 0x81500
movq 0x48(%rsp), %rdi
leaq 0x6ff(%rip), %rsi       # 0x2f22b0
callq 0x81500
movq 0x70(%rsp), %rdi
movq 0x48(%rsp), %rsi
leaq 0x6e9(%rip), %rdx       # 0x2f22b0
callq 0x81840
testb $0x1, %al
jne 0x2f1cd3
movq $0x3c, 0x38(%rsp)
movq 0x34a3bc(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
movq 0x90(%rsp), %rdx
leaq 0x29d970(%rip), %rsi    # 0x58f566
movb $0x0, %al
callq 0x199f0
movq 0x34a39c(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x29d979(%rip), %rsi    # 0x58f587
movb $0x0, %al
callq 0x199f0
movq 0x70(%rsp), %rdi
movq 0xc0(%rsp), %rcx
leaq 0x7a7(%rip), %rsi       # 0x2f23d0
xorl %eax, %eax
movl %eax, %edx
callq 0x81980
movq 0x34a367(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x29d952(%rip), %rsi    # 0x58f595
movb $0x0, %al
callq 0x199f0
movq 0x48(%rsp), %rdi
movq 0xc0(%rsp), %rcx
leaq 0x772(%rip), %rsi       # 0x2f23d0
xorl %eax, %eax
movl %eax, %edx
callq 0x81980
movq 0x34a332(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
movq 0x78(%rsp), %rdx
movq 0x88(%rsp), %rcx
movq 0x98(%rsp), %r8
leaq 0x29d913(%rip), %rsi    # 0x58f5a0
movl $0x3c, %r9d
callq 0x21e230
movq 0x34a301(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %rcx
movq 0x90(%rsp), %r8
leaq 0x29d8e8(%rip), %rsi    # 0x58f5a6
movl $0x3c, %r9d
callq 0x21e230
movl $0x2, %edi
callq 0x19890
movq 0x58(%rsp), %rdi
leaq 0x29d7ce(%rip), %rsi    # 0x58f4ad
movl $0x185, %edx            # imm = 0x185
callq 0xe88c0
movq 0x70(%rsp), %rdi
callq 0x81f80
movq 0x48(%rsp), %rdi
callq 0x81f80
movq 0xa8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa8(%rsp)
jmp 0x2f1819
movq 0x88(%rsp), %rdi
leaq 0x29d788(%rip), %rsi    # 0x58f4ad
movl $0x189, %edx            # imm = 0x189
callq 0xe88c0
movq 0xb0(%rsp), %rdi
callq 0xae070
movb 0xbf(%rsp), %dl
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb $0x1, %dl
cmovnel %ecx, %eax
addq $0xf0, %rsp
popq %rbx
retq
nopl (%rax)