// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/match_iterator_sw.c
// Function: gt_match_iterator_sw_next
static GtMatchIteratorStatus gt_match_iterator_sw_next(GtMatchIterator *mi,
                                                      GT_UNUSED GtMatch **match,
                                                      GT_UNUSED GtError *err)
{
  GtMatchIteratorSW *mis;
  GtSeq *seq_a, *seq_b;
  char *a, *b;
  const char *adesc, *bdesc;
  GtAlignment *ali = NULL;
  GtUword seqlen_a, seqlen_b, seqpos;
  GtRange arng, brng;
  gt_assert(mi && match);

  mis = gt_match_iterator_sw_cast(mi);
  while (true) {
    if (!mis->pvt->firstali)
      mis->pvt->seqno_es2++;
    if (mis->pvt->seqno_es2 == gt_encseq_num_of_sequences(mis->pvt->es2)) {
      mis->pvt->seqno_es1++;
      if (mis->pvt->seqno_es1 == gt_encseq_num_of_sequences(mis->pvt->es1))
        return GT_MATCHER_STATUS_END;
      mis->pvt->seqno_es2 = 0;
    }
    seqlen_a = gt_encseq_seqlength(mis->pvt->es1, mis->pvt->seqno_es1);
    seqlen_b = gt_encseq_seqlength(mis->pvt->es2, mis->pvt->seqno_es2);
    /* XXX: reuse buffers for performance improvement */
    a = gt_malloc(seqlen_a * sizeof (char));
    seqpos = gt_encseq_seqstartpos(mis->pvt->es1, mis->pvt->seqno_es1);
    gt_encseq_extract_decoded(mis->pvt->es1, a, seqpos, seqpos + seqlen_a - 1);
    b = gt_malloc(seqlen_b * sizeof (char));
    seqpos = gt_encseq_seqstartpos(mis->pvt->es2, mis->pvt->seqno_es2);
    gt_encseq_extract_decoded(mis->pvt->es1, b, seqpos, seqpos + seqlen_b - 1);
    seq_a = gt_seq_new(a, seqlen_a, gt_encseq_alphabet(mis->pvt->es1));
    seq_b = gt_seq_new(b, seqlen_b, gt_encseq_alphabet(mis->pvt->es2));
    ali = gt_swalign(seq_a, seq_b, mis->pvt->sf);
    mis->pvt->firstali = false;
    if (ali && gt_alignment_get_length(ali) >= mis->pvt->min_len
          && gt_alignment_eval(ali) <= mis->pvt->max_edist) {
      break;
    }
    gt_alignment_delete(ali);
    gt_seq_delete(seq_a);
    gt_seq_delete(seq_b);
    gt_free(a);
    gt_free(b);
  }
  arng = gt_alignment_get_urange(ali);
  brng = gt_alignment_get_vrange(ali);
  adesc = gt_encseq_description(mis->pvt->es1, &seqlen_a, mis->pvt->seqno_es1);
  bdesc = gt_encseq_description(mis->pvt->es2, &seqlen_b, mis->pvt->seqno_es2);
  *match = gt_match_sw_new("", "",
                           mis->pvt->seqno_es1,
                           mis->pvt->seqno_es2,
                           gt_alignment_get_length(ali),
                           gt_alignment_eval(ali),
                           arng.start, brng.start,
                           arng.end, brng.end,
                           GT_MATCH_DIRECT);
  gt_match_set_seqid1_nt(*match, adesc, seqlen_a);
  gt_match_set_seqid2_nt(*match, bdesc, seqlen_b);
  gt_alignment_delete(ali);
  gt_seq_delete(seq_a);
  gt_seq_delete(seq_b);
  gt_free(a);
  gt_free(b);
  return GT_MATCHER_STATUS_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
testq %rdi, %rdi
je 0xfed36
testq %rsi, %rsi
je 0xfed36
movq %rdi, %rbx
movq %rsi, 0x40(%rsp)
callq 0xfe9c4
movq %rax, %rdi
movq %rbx, %rsi
callq 0xfc6cb
movq %rax, %r14
leaq 0x228ebe(%rip), %r12    # 0x3278f4
movq 0x8(%r14), %rax
movq 0x20(%rax), %rbx
cmpb $0x0, 0x38(%rax)
jne 0xfea4b
incq %rbx
movq %rbx, 0x20(%rax)
movq 0x10(%rax), %rdi
callq 0x705a1
movq 0x8(%r14), %rcx
cmpq %rax, %rbx
jne 0xfea83
movq 0x8(%rcx), %rdi
movq 0x18(%rcx), %rbx
incq %rbx
movq %rbx, 0x18(%rcx)
callq 0x705a1
cmpq %rax, %rbx
je 0xfebed
movq 0x8(%r14), %rcx
andq $0x0, 0x20(%rcx)
movq 0x8(%rcx), %rdi
movq 0x18(%rcx), %rsi
callq 0x75173
movq %rax, %r13
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rax), %rsi
callq 0x75173
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
pushq $0x4e
popq %rdx
callq 0x93160
movq %rax, %rbx
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
movq 0x18(%rax), %rsi
callq 0x74d9c
movq 0x8(%r14), %rcx
movq 0x8(%rcx), %rdi
leaq (%rax,%r13), %rcx
decq %rcx
movq %rbx, %rsi
movq %rax, %rdx
callq 0x7239d
movq %r15, %rdi
movq %r12, %rsi
pushq $0x51
popq %rdx
callq 0x93160
movq %rax, %r12
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rax), %rsi
callq 0x74d9c
movq 0x8(%r14), %rcx
movq 0x8(%rcx), %rdi
leaq (%rax,%r15), %rcx
decq %rcx
movq %r12, %rsi
movq %rax, %rdx
callq 0x7239d
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
callq 0x754dd
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xa55d4
movq %rax, %rbx
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
callq 0x754dd
movq %r12, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xa55d4
movq %rax, %rbp
movq 0x8(%r14), %rax
movq (%rax), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x124dc8
movq %rax, %r12
movq 0x8(%r14), %rax
movb $0x0, 0x38(%rax)
testq %r12, %r12
je 0xfebaa
movq %r12, %rdi
callq 0xb5085
movq 0x8(%r14), %rcx
cmpq 0x28(%rcx), %rax
jb 0xfebaa
movq %r12, %rdi
callq 0xb55be
movq 0x8(%r14), %rcx
cmpq 0x30(%rcx), %rax
jbe 0xfebf5
movq %r12, %rdi
callq 0xb647f
movq %rbx, %rdi
callq 0xa58aa
movq %rbp, %rdi
callq 0xa58aa
movq 0x8(%rsp), %rdi
leaq 0x228d26(%rip), %r12    # 0x3278f4
movq %r12, %rsi
pushq $0x5f
popq %rdx
callq 0x936f9
movq (%rsp), %rdi
movq %r12, %rsi
pushq $0x60
popq %rdx
callq 0x936f9
jmp 0xfea36
pushq $0x1
popq %rax
jmp 0xfed27
leaq 0x50(%rsp), %rax
movq %r13, (%rax)
movq %rax, %r13
leaq 0x48(%rsp), %rax
movq %r15, (%rax)
movq %rax, %r15
movq %r12, %rdi
callq 0xb5000
movq %rax, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %r12, %rdi
callq 0xb5113
movq %rax, 0x28(%rsp)
movq %rdx, 0x10(%rsp)
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
movq 0x18(%rax), %rdx
movq %r13, %rsi
callq 0x75b24
movq %rax, 0x20(%rsp)
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rax), %rdx
movq %r15, %rsi
callq 0x75b24
movq %rax, 0x18(%rsp)
movq 0x8(%r14), %rax
movq 0x18(%rax), %r14
movq 0x20(%rax), %r15
movq %r12, %rdi
callq 0xb5085
movq %rax, %r13
movq %r12, %rdi
callq 0xb55be
subq $0x8, %rsp
leaq 0x26b8e5(%rip), %rdi    # 0x36a570
movq %rdi, %rsi
movq %r14, %rdx
movq %r15, %rcx
movq %r13, %r8
movq %rax, %r9
pushq $0x0
pushq 0x20(%rsp)
pushq 0x48(%rsp)
pushq 0x48(%rsp)
pushq 0x60(%rsp)
callq 0xff13d
addq $0x30, %rsp
movq 0x40(%rsp), %r14
movq %rax, (%r14)
leaq 0x50(%rsp), %rcx
movq (%rcx), %rdx
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0xfbcad
movq (%r14), %rdi
leaq 0x48(%rsp), %rax
movq (%rax), %rdx
movq 0x18(%rsp), %rsi
callq 0xfbd2b
movq %r12, %rdi
callq 0xb647f
movq %rbx, %rdi
callq 0xa58aa
movq %rbp, %rdi
callq 0xa58aa
leaq 0x228bee(%rip), %rbx    # 0x3278f4
pushq $0x73
popq %rdx
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x936f9
pushq $0x74
popq %rdx
movq (%rsp), %rdi
movq %rbx, %rsi
callq 0x936f9
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x33922b(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1e62cc(%rip), %rsi    # 0x2e5013
leaq 0x228bc7(%rip), %rdx    # 0x327915
leaq 0x228bcc(%rip), %rcx    # 0x327921
leaq 0x228b98(%rip), %r8     # 0x3278f4
pushq $0x3f
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390