// File: /workspace/github_c_makefile_star2_O1/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 $0x78, %rsp
movq %r9, %r12
movq %r8, %r13
movq %rcx, %rbp
movl %edx, (%rsp)
movq %rsi, %rdx
movq %rdi, %rbx
leaq 0x1bc2b8(%rip), %rsi    # 0x3c5a33
xorl %r14d, %r14d
movq %r8, %rdi
movq %rdx, 0x38(%rsp)
xorl %eax, %eax
callq 0x10906e
callq 0xf36ef
movq %rax, %r15
movq %rax, %rdi
callq 0xf69ed
movq %r15, %rdi
callq 0xf6a1a
movq %r15, %rdi
callq 0xf6a49
movq %r15, %rdi
movq %r13, 0x40(%rsp)
movq %r13, %rsi
callq 0xf6add
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0xf374b
movq %rax, %r13
movq %r15, %rdi
callq 0xf424d
testq %r13, %r13
je 0x2097ed
movq %r13, %rdi
callq 0xec1d8
movq %rax, %r14
shrq %r14
xorl %ecx, %ecx
jmp 0x2097ef
movb $0x1, %cl
testb %cl, %cl
movq %rbp, %r15
movq 0x38(%rsp), %rbx
movl %ecx, 0x4(%rsp)
je 0x20980d
xorl %r14d, %r14d
movq $0x0, 0x10(%rsp)
jmp 0x209841
cmpq %r15, %r14
cmovbq %r14, %r15
leaq 0x1(,%r15,2), %rdi
leaq 0x1bc221(%rip), %rsi    # 0x3c5a44
movl $0x136, %edx            # imm = 0x136
callq 0x1092b2
movq %rax, %r14
movq %r13, %rdi
callq 0xf02da
movl 0x4(%rsp), %ecx
movq %rax, 0x10(%rsp)
testq %rbx, %rbx
sete %al
orb %cl, %al
movq %r13, 0x18(%rsp)
je 0x209857
movl %ecx, %ebx
jmp 0x209b0f
movq %r12, 0x8(%rsp)
movl (%rsp), %eax
movq %rax, 0x48(%rsp)
xorl %r12d, %r12d
movq %r15, 0x20(%rsp)
xorl %edi, %edi
movq %r14, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x209c28
testq %r14, %r14
je 0x209b4d
movq %r13, %rdx
movq %rax, %r13
leaq (%r14,%rax), %rbp
incq %rbp
movb $-0x1, (%r14,%rax)
movl $0x1, %edi
movq %rbp, %rsi
movq %r15, %rcx
callq 0x209c28
cmpq 0x48(%rsp), %rax
jb 0x209ae9
cmpq 0x48(%rsp), %r13
jb 0x209ae9
cmpb $-0x1, (%r14)
je 0x209ae9
cmpb $-0x1, (%rbp)
je 0x209ae9
movq %rax, %r15
movq 0x20(%rsp), %rax
cmpb $-0x1, -0x1(%r14,%rax)
je 0x209ae9
leaq (%r14,%r13), %rax
movq 0x20(%rsp), %rcx
cmpb $-0x1, (%rax,%rcx)
je 0x209ae9
movq 0x40(%rsp), %rdi
leaq 0x1bc178(%rip), %rsi    # 0x3c5a7c
movq %r13, %rdx
movq %r15, %rcx
movl (%rsp), %ebx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x10906e
movl $0x20, %edi
callq 0xd46fc
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r15, %rcx
movl %ebx, %r8d
movq 0x10(%rsp), %r9
pushq 0x8(%rsp)
movq 0x48(%rsp), %r10
movq %r10, %rbx
pushq %r10
movq %rax, 0x40(%rsp)
pushq %rax
leaq 0x37a(%rip), %rax       # 0x209cca
pushq %rax
callq 0x1acb78
addq $0x20, %rsp
testl %eax, %eax
jne 0x209b49
movq %rbx, %rdi
leaq 0x1bc14a(%rip), %rsi    # 0x3c5ab6
movq %r13, %rdx
movq %r15, %rcx
movl (%rsp), %r8d
xorl %eax, %eax
callq 0x10906e
movl $0x20, %edi
callq 0xd46fc
movq %rax, 0x50(%rsp)
movq %r13, 0x58(%rsp)
movq %r15, 0x68(%rsp)
movq $0x1, 0x70(%rsp)
testq %r15, %r15
je 0x2099c2
movq 0x70(%rsp), %rax
xorl %ecx, %ecx
cmpb $-0x1, (%rbp,%rcx)
jne 0x2099ba
incq %rax
movq %rax, 0x70(%rsp)
incq %rcx
cmpq %rcx, %r15
jne 0x2099ab
movq 0x70(%rsp), %rax
cmpq $0x1, %rax
jne 0x2099d1
xorl %eax, %eax
jmp 0x209a09
leaq -0x8(,%rax,8), %rdi
leaq 0x1bc064(%rip), %rsi    # 0x3c5a44
movl $0x103, %edx            # imm = 0x103
callq 0x1092b2
testq %r15, %r15
je 0x209a09
xorl %ecx, %ecx
xorl %edx, %edx
cmpb $-0x1, (%rbp,%rdx)
jne 0x209a01
movq %rdx, (%rax,%rcx,8)
incq %rcx
incq %rdx
cmpq %rdx, %r15
jne 0x2099f3
movq %rax, 0x60(%rsp)
leaq (%r15,%r13), %rbx
incq %rbx
movq 0x18(%rsp), %rdi
callq 0xf02b7
movl %eax, %r8d
movl $0x1, %edi
movq %r14, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
movq 0x8(%rsp), %r9
callq 0x1fcc5c
movq %rax, %rbx
testq %rax, %rax
je 0x209b41
movq %rbx, %rdi
movl (%rsp), %esi
leaq 0x2df(%rip), %rdx       # 0x209d31
leaq 0x50(%rsp), %rcx
movq 0x8(%rsp), %r8
callq 0x1ab883
movl %eax, 0x2c(%rsp)
movq %rbx, %rdi
callq 0x1fcd9a
cmpl $0x0, 0x2c(%rsp)
movb $0x1, %bl
jne 0x209b0f
movq 0x30(%rsp), %rdi
leaq 0x36c(%rip), %rbx       # 0x209df2
movq %rbx, %rsi
callq 0xd4ae7
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0xd4ae7
movq 0x50(%rsp), %rsi
movq 0x30(%rsp), %rdi
movq %rdi, %rbx
leaq 0x343(%rip), %rdx       # 0x209df2
callq 0xd4bea
testb %al, %al
je 0x209b52
movq 0x60(%rsp), %rdi
leaq 0x1bbf7c(%rip), %rsi    # 0x3c5a44
movl $0x185, %edx            # imm = 0x185
callq 0x109670
movq %rbx, %rdi
callq 0xd4ef4
movq 0x50(%rsp), %rdi
callq 0xd4ef4
movq 0x38(%rsp), %rbx
incq %r12
cmpq %rbx, %r12
jae 0x209b09
movl 0x4(%rsp), %eax
testb %al, %al
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %r13
je 0x20986c
jmp 0x209b0d
movl 0x4(%rsp), %eax
movl %eax, %ebx
leaq 0x1bbf2e(%rip), %rsi    # 0x3c5a44
movq %r14, %rdi
movl $0x189, %edx            # imm = 0x189
callq 0x109670
movq 0x18(%rsp), %rdi
callq 0xee90c
movzbl %bl, %eax
negl %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x1fcd9a
movb $0x1, %bl
jmp 0x209b0f
callq 0x80f94
movq 0x2ba427(%rip), %rax    # 0x4c3f80
movq (%rax), %rdi
movq %rax, %r12
leaq 0x1bbf89(%rip), %rsi    # 0x3c5aef
movq %r15, %rdx
xorl %eax, %eax
callq 0x17ab0
movq (%r12), %rcx
leaq 0x1bbf95(%rip), %rdi    # 0x3c5b10
movl $0xd, %esi
movl $0x1, %edx
callq 0x17fa0
leaq 0x2a5(%rip), %rsi       # 0x209e36
movq %rbx, %rdi
xorl %edx, %edx
movq 0x8(%rsp), %r12
movq %r12, %rcx
callq 0xd4c8e
movq 0x2ba3d6(%rip), %rbx    # 0x4c3f80
movq (%rbx), %rcx
leaq 0x1bbf6a(%rip), %rdi    # 0x3c5b1e
movl $0xa, %esi
movl $0x1, %edx
callq 0x17fa0
movq 0x50(%rsp), %rdi
leaq 0x267(%rip), %rsi       # 0x209e36
xorl %edx, %edx
movq %r12, %rcx
callq 0xd4c8e
movq (%rbx), %rdi
movq %rbx, %r12
leaq 0x1bbf43(%rip), %rsi    # 0x3c5b29
movl $0x3c, %r9d
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
movq %r14, %rcx
movq %r13, %r8
callq 0x1a0f70
movq (%r12), %rdi
leaq 0x1bbf25(%rip), %rsi    # 0x3c5b2f
movl $0x3c, %r9d
movq %rbx, %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x1a0f70
movl $0x2, %edi
callq 0x17940