// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/ltr/ltr_cluster_stream.c
// Function: cluster_sequences
static int cluster_sequences(GtArray *matches,
                             GtClusteredSet *cs,
                             GtHashmap *seqdesc2seqnum,
                             unsigned int psmall,
                             unsigned int plarge,
                             GtEncseq *encseq,
                             GtError *err)
{
  GtMatch *match;
  GtMatchEdgeTable matchedgetab;
  GtMatchEdge matchedge;
  GtRange rng_seq1,
          rng_seq2;
  int had_err = 0;
  GtUword i,
                lsmall,
                llarge,
                matchlen1,
                matchlen2,
                num_of_seq,
                seqnum1 = 0,
                seqnum2 = 0;
  const char *seqid;

  num_of_seq = gt_encseq_num_of_sequences(encseq);
  gt_assert(matches && cs && seqdesc2seqnum && encseq);

  if (gt_clustered_set_num_of_elements(cs, err) != num_of_seq) {
    had_err = -1;
    gt_error_set(err,
                 "number of sequences ("GT_WU") unequals number of elements in"
                 " clustered set ("GT_WU")",
                 num_of_seq, gt_clustered_set_num_of_elements(cs, err));
  }
  if (!had_err) {
    matchedgetab.edges = gt_array_new(sizeof (GtMatchEdge));
    matchedgetab.num_of_edges = 0;

    for (i = 0; i < gt_array_size(matches); i++) {
      match = *(GtMatch**) gt_array_get(matches, i);
      gt_match_get_range_seq1(match, &rng_seq1);
      gt_match_get_range_seq2(match, &rng_seq2);

      matchlen1 =  gt_range_length(&rng_seq1);
      matchlen2 =  gt_range_length(&rng_seq2);

      seqid = gt_match_get_seqid1(match);
      if (gt_hashmap_get(seqdesc2seqnum, (void*) seqid) != NULL)
        seqnum1 = ((GtUword) gt_hashmap_get(seqdesc2seqnum, seqid)) - 1;
      else {
        had_err = -1;
        gt_error_set(err, "key %s not found", seqid);
      }

      seqid = gt_match_get_seqid2(match);
      if (!had_err && gt_hashmap_get(seqdesc2seqnum, (void*) seqid) != NULL)
        seqnum2 = ((GtUword) gt_hashmap_get(seqdesc2seqnum, seqid)) - 1;
      else {
        had_err = -1;
        gt_error_set(err, "key %s not found", seqid);
      }

      if (!had_err) {
        if (gt_encseq_seqlength(encseq, seqnum1) >
            gt_encseq_seqlength(encseq, seqnum2)) {
          llarge = gt_encseq_seqlength(encseq, seqnum1);
          lsmall = gt_encseq_seqlength(encseq, seqnum2);
        } else {
          lsmall = gt_encseq_seqlength(encseq, seqnum1);
          llarge = gt_encseq_seqlength(encseq, seqnum2);
        }
        if (((llarge * plarge)/100 <= matchlen1) &&
            ((lsmall * psmall)/100 <= matchlen1) &&
            ((llarge * plarge)/100 <= matchlen2) &&
            ((lsmall * psmall)/100 <= matchlen2)) {
          if (seqnum1 != seqnum2) {
            matchedge.matchnum0 = seqnum1;
            matchedge.matchnum1 = seqnum2;
            gt_array_add(matchedgetab.edges, matchedge);
            matchedgetab.num_of_edges++;
          }
        }
      }
    }
  }
  if (!had_err)
    if (gt_cluster_matches(cs, &matchedgetab, err) != 0)
      had_err = -1;
  if (!had_err)
    gt_array_delete(matchedgetab.edges);
  return had_err;
}

// Assembly:
subq $0xf8, %rsp
movq 0x100(%rsp), %rax
movq %rdi, 0xf0(%rsp)
movq %rsi, 0xe8(%rsp)
movq %rdx, 0xe0(%rsp)
movl %ecx, 0xdc(%rsp)
movl %r8d, 0xd8(%rsp)
movq %r9, 0xd0(%rsp)
movl $0x0, 0x6c(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq 0xd0(%rsp), %rdi
callq 0xa9d50
movq %rax, 0x38(%rsp)
cmpq $0x0, 0xf0(%rsp)
je 0x2ffdf6
cmpq $0x0, 0xe8(%rsp)
je 0x2ffdf6
cmpq $0x0, 0xe0(%rsp)
je 0x2ffdf6
cmpq $0x0, 0xd0(%rsp)
jne 0x2ffe2e
movq 0x33c1a3(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x21620c(%rip), %rsi    # 0x516013
leaq 0x2928ec(%rip), %rdx    # 0x5926fa
leaq 0x29290f(%rip), %rcx    # 0x592724
leaq 0x292859(%rip), %r8     # 0x592675
movl $0xaa, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2ffe30
movq 0xe8(%rsp), %rdi
movq 0x100(%rsp), %rsi
callq 0x48bd10
cmpq 0x38(%rsp), %rax
je 0x2ffe9b
movl $0xffffffff, 0x6c(%rsp) # imm = 0xFFFFFFFF
movq 0x100(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xe8(%rsp), %rdi
movq 0x100(%rsp), %rsi
callq 0x48bd10
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
movq %rax, %rcx
leaq 0x2928a2(%rip), %rsi    # 0x592736
movb $0x0, %al
callq 0xd88c0
cmpl $0x0, 0x6c(%rsp)
jne 0x3001cd
movl $0x28, %edi
callq 0x80990
movq %rax, 0xb8(%rsp)
movq $0x0, 0xc0(%rsp)
movq $0x0, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x81370
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x3001cb
movq 0xf0(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x80b60
movq (%rax), %rax
movq %rax, 0xc8(%rsp)
movq 0xc8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1a6ce0
movq 0xc8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x1a6d60
leaq 0x80(%rsp), %rdi
callq 0x107320
movq %rax, 0x48(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x107320
movq %rax, 0x40(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x1a6c20
movq %rax, 0x20(%rsp)
movq 0xe0(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0xe0f20
cmpq $0x0, %rax
je 0x2fffa1
movq 0xe0(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0xe0f20
subq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x2fffc4
movl $0xffffffff, 0x6c(%rsp) # imm = 0xFFFFFFFF
movq 0x100(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0x2927c6(%rip), %rsi    # 0x592783
movb $0x0, %al
callq 0xd88c0
movq 0xc8(%rsp), %rdi
callq 0x1a6c80
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x6c(%rsp)
jne 0x300012
movq 0xe0(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0xe0f20
cmpq $0x0, %rax
je 0x300012
movq 0xe0(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0xe0f20
subq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x300035
movl $0xffffffff, 0x6c(%rsp) # imm = 0xFFFFFFFF
movq 0x100(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0x292755(%rip), %rsi    # 0x592783
movb $0x0, %al
callq 0xd88c0
cmpl $0x0, 0x6c(%rsp)
jne 0x3001b6
movq 0xd0(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0xb09f0
movq %rax, (%rsp)
movq 0xd0(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0xb09f0
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
jbe 0x3000a4
movq 0xd0(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0xb09f0
movq %rax, 0x50(%rsp)
movq 0xd0(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0xb09f0
movq %rax, 0x58(%rsp)
jmp 0x3000d2
movq 0xd0(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0xb09f0
movq %rax, 0x58(%rsp)
movq 0xd0(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0xb09f0
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movl 0xd8(%rsp), %ecx
imulq %rcx, %rax
movl $0x64, %ecx
xorl %edx, %edx
divq %rcx
cmpq 0x48(%rsp), %rax
ja 0x3001b4
movq 0x58(%rsp), %rax
movl 0xdc(%rsp), %ecx
imulq %rcx, %rax
movl $0x64, %ecx
xorl %edx, %edx
divq %rcx
cmpq 0x48(%rsp), %rax
ja 0x3001b4
movq 0x50(%rsp), %rax
movl 0xd8(%rsp), %ecx
imulq %rcx, %rax
movl $0x64, %ecx
xorl %edx, %edx
divq %rcx
cmpq 0x40(%rsp), %rax
ja 0x3001b4
movq 0x58(%rsp), %rax
movl 0xdc(%rsp), %ecx
imulq %rcx, %rax
movl $0x64, %ecx
xorl %edx, %edx
divq %rcx
cmpq 0x40(%rsp), %rax
ja 0x3001b4
movq 0x30(%rsp), %rax
cmpq 0x28(%rsp), %rax
je 0x3001b2
movq 0x30(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0xb8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
movl $0x28, %edx
callq 0x81100
movq 0xc0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xc0(%rsp)
jmp 0x3001b4
jmp 0x3001b6
jmp 0x3001b8
movq 0x60(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
jmp 0x2ffecd
jmp 0x3001cd
cmpl $0x0, 0x6c(%rsp)
jne 0x300200
movq 0xe8(%rsp), %rdi
movq 0x100(%rsp), %rdx
leaq 0xb8(%rsp), %rsi
callq 0x300900
cmpl $0x0, %eax
je 0x3001fe
movl $0xffffffff, 0x6c(%rsp) # imm = 0xFFFFFFFF
jmp 0x300200
cmpl $0x0, 0x6c(%rsp)
jne 0x300214
movq 0xb8(%rsp), %rdi
callq 0x81f80
movl 0x6c(%rsp), %eax
addq $0xf8, %rsp
retq