// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, %rbx
movq %r8, %rbp
movq %rcx, %r15
movl %edx, %r13d
movq %rsi, %rdx
movq %rdi, %r14
leaq 0x1a8c3f(%rip), %rsi    # 0x35c815
movq %r8, %rdi
movq %rdx, 0x80(%rsp)
xorl %eax, %eax
callq 0x92e71
callq 0x791cd
movq %rax, %r12
movq %rax, %rdi
callq 0x7d0cd
movq %r12, %rdi
callq 0x7d193
movq %r12, %rdi
callq 0x7d25b
movq %r12, %rdi
movq %rbp, 0x48(%rsp)
movq %rbp, %rsi
callq 0x7d487
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7921d
movq %r12, %rdi
movq %rax, %r12
callq 0x79f01
pushq $-0x1
popq %rbp
testq %r12, %r12
je 0x1b3f45
movq %r12, %rdi
callq 0x7055e
movq %rax, %rbp
shrq %rbp
cmpq %r15, %rbp
cmovaeq %r15, %rbp
leaq 0x1(,%rbp,2), %rdi
leaq 0x1a8bc5(%rip), %rsi    # 0x35c826
movl $0x136, %edx            # imm = 0x136
callq 0x93160
movq %rax, 0x8(%rsp)
movq %r12, %rdi
callq 0x754dd
movq %rax, 0x38(%rsp)
movl %r13d, %eax
movq %rax, 0x78(%rsp)
pushq $0x20
popq %r14
movq %rbx, 0x20(%rsp)
xorl %ebx, %ebx
movl %r13d, 0x14(%rsp)
movq %r12, 0x18(%rsp)
movq %rbp, 0x28(%rsp)
cmpq 0x80(%rsp), %rbx
je 0x1b3f41
xorl %edi, %edi
movq 0x8(%rsp), %r15
movq %r15, %rsi
movq %r12, %rdx
movq %rbp, %rcx
callq 0x1b4085
movq %r15, %rdx
testq %r15, %r15
je 0x1b3f91
movq %rax, %r15
movq %rbp, %rcx
leaq (%rdx,%rax), %rbp
incq %rbp
movb $-0x1, (%rdx,%rax)
pushq $0x1
popq %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x1b4085
movq %rax, %r12
movq 0x78(%rsp), %rcx
cmpq %rcx, %rax
setb %al
cmpq %rcx, %r15
setb %cl
orb %al, %cl
jne 0x1b3ef6
movq 0x8(%rsp), %rax
cmpb $-0x1, (%rax)
je 0x1b3ef6
cmpb $-0x1, (%rbp)
je 0x1b3ef6
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rcx
cmpb $-0x1, -0x1(%rcx,%rax)
je 0x1b3ef6
movq 0x8(%rsp), %rax
addq %r15, %rax
movq 0x28(%rsp), %rcx
cmpb $-0x1, (%rax,%rcx)
je 0x1b3ef6
movq 0x48(%rsp), %rdi
leaq 0x1a8b05(%rip), %rsi    # 0x35c85e
movq %r15, %rdx
movq %r12, %rcx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x92e71
movq %r14, %rdi
callq 0x5809c
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movl %r13d, %r8d
movq 0x38(%rsp), %r9
pushq 0x20(%rsp)
movq 0x50(%rsp), %r13
pushq %r13
movq %rax, 0x50(%rsp)
pushq %rax
leaq 0x3bb(%rip), %rax       # 0x1b415a
pushq %rax
callq 0x14ff8d
addq $0x20, %rsp
testl %eax, %eax
jne 0x1b3f57
movq %r13, %rdi
leaq 0x1a8add(%rip), %rsi    # 0x35c898
movq %r15, %rdx
movq %r12, %rcx
movl 0x14(%rsp), %r8d
xorl %eax, %eax
callq 0x92e71
pushq $0x20
popq %rdi
callq 0x5809c
movq %rax, 0x50(%rsp)
movq %r15, 0x58(%rsp)
movq %r12, 0x68(%rsp)
movq $0x1, 0x70(%rsp)
pushq $0x1
popq %rax
xorl %ecx, %ecx
cmpq %rcx, %r12
je 0x1b3e0b
cmpb $-0x1, (%rbp,%rcx)
jne 0x1b3e06
incq %rax
movq %rax, 0x70(%rsp)
incq %rcx
jmp 0x1b3df2
cmpq $0x1, %rax
jne 0x1b3f08
xorl %eax, %eax
movq %rax, 0x60(%rsp)
leaq (%r15,%r12), %r13
incq %r13
movq 0x18(%rsp), %rdi
callq 0x75487
movl %eax, %r8d
pushq $0x1
popq %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
xorl %ecx, %ecx
movq 0x20(%rsp), %r9
callq 0x1a50c6
testq %rax, %rax
je 0x1b3f50
movq %rax, %r13
movq %rax, %rdi
movl 0x14(%rsp), %esi
leaq 0x35e(%rip), %rdx       # 0x1b41bf
leaq 0x50(%rsp), %rcx
movq 0x20(%rsp), %r8
callq 0x14eb82
movl %eax, 0x34(%rsp)
movq %r13, %rdi
callq 0x1a5212
cmpl $0x0, 0x34(%rsp)
jne 0x1b3f57
movq 0x40(%rsp), %rdi
leaq 0x3e5(%rip), %r13       # 0x1b4278
movq %r13, %rsi
callq 0x587b0
movq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x587b0
movq 0x50(%rsp), %rsi
movq 0x40(%rsp), %rdi
movq %rdi, %r13
leaq 0x3bc(%rip), %rdx       # 0x1b4278
callq 0x589db
testb %al, %al
je 0x1b3fc9
movq 0x60(%rsp), %rdi
leaq 0x1a8951(%rip), %rsi    # 0x35c826
movl $0x185, %edx            # imm = 0x185
callq 0x936f9
movq %r13, %rdi
callq 0x58eb9
movq 0x50(%rsp), %rdi
callq 0x58eb9
movl 0x14(%rsp), %r13d
incq %rbx
movq 0x18(%rsp), %r12
movq 0x28(%rsp), %rbp
jmp 0x1b3c9f
leaq -0x8(,%rax,8), %rdi
leaq 0x1a890f(%rip), %rsi    # 0x35c826
movl $0x103, %edx            # imm = 0x103
callq 0x93160
xorl %ecx, %ecx
xorl %edx, %edx
cmpq %rcx, %r12
je 0x1b3e17
cmpb $-0x1, (%rbp,%rcx)
jne 0x1b3f3c
movq %rcx, (%rax,%rdx,8)
incq %rdx
incq %rcx
jmp 0x1b3f25
xorl %ebp, %ebp
jmp 0x1b3f5f
movq $0x0, 0x8(%rsp)
jmp 0x1b3f5f
xorl %edi, %edi
callq 0x1a5212
movq 0x18(%rsp), %r12
pushq $-0x1
popq %rbp
leaq 0x1a88c0(%rip), %rsi    # 0x35c826
movq 0x8(%rsp), %rdi
movl $0x189, %edx            # imm = 0x189
callq 0x936f9
movq %r12, %rdi
callq 0x735fd
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x283fd0(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x131071(%rip), %rsi    # 0x2e5013
leaq 0x1a8897(%rip), %rdx    # 0x35c840
leaq 0x1a889e(%rip), %rcx    # 0x35c84e
leaq 0x1a886f(%rip), %r8     # 0x35c826
movl $0x13c, %r9d            # imm = 0x13C
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x283f98(%rip), %rbx    # 0x437f68
movq (%rbx), %rdi
leaq 0x1a88f7(%rip), %rsi    # 0x35c8d1
movq %r12, %rdx
xorl %eax, %eax
callq 0x17a50
movq (%rbx), %rcx
leaq 0x1a8904(%rip), %rdi    # 0x35c8f2
pushq $0xd
popq %rsi
pushq $0x1
popq %rdx
callq 0x17f00
leaq 0x2b7(%rip), %rsi       # 0x1b42b7
movq %r13, %rdi
movq %rsi, %r13
xorl %edx, %edx
movq 0x20(%rsp), %r14
movq %r14, %rcx
callq 0x58aa6
movq (%rbx), %rcx
leaq 0x1a88e1(%rip), %rdi    # 0x35c900
pushq $0xa
popq %rsi
pushq $0x1
popq %rdx
callq 0x17f00
movq 0x50(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x58aa6
movq (%rbx), %rdi
leaq 0x1a88c5(%rip), %rsi    # 0x35c90b
pushq $0x3c
popq %r14
movq 0x38(%rsp), %r13
movq %r13, %rdx
movq 0x8(%rsp), %rcx
movq %r15, %r8
movq %r14, %r9
callq 0x142c20
movq (%rbx), %rdi
leaq 0x1a88a5(%rip), %rsi    # 0x35c911
movq %r13, %rdx
movq %rbp, %rcx
movq %r12, %r8
movq %r14, %r9
callq 0x142c20
pushq $0x2
popq %rdi
callq 0x178f0