// File: /workspace/github_c_makefile_star2_O1/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 0x167e65
testq %rsi, %rsi
je 0x167e65
movq %rdi, %rbx
movq %rsi, 0x50(%rsp)
cmpq $0x0, 0x361c96(%rip)    # 0x4c97b0
jne 0x167b3b
leaq -0x39(%rip), %rsi       # 0x167aea
leaq 0x340(%rip), %rdx       # 0x167e6a
movl $0x10, %edi
callq 0x165afc
movq %rax, 0x361c75(%rip)    # 0x4c97b0
movq 0x361c6e(%rip), %rdi    # 0x4c97b0
movq %rbx, %rsi
callq 0x165b75
movq %rax, %r14
leaq 0x228d84(%rip), %r13    # 0x3908d8
movq 0x8(%r14), %rax
cmpb $0x0, 0x38(%rax)
jne 0x167b62
incq 0x20(%rax)
movq 0x10(%rax), %rdi
movq 0x20(%rax), %rbx
callq 0xec1e8
cmpq %rax, %rbx
jne 0x167ba1
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
movq 0x18(%rax), %rbx
incq %rbx
movq %rbx, 0x18(%rax)
callq 0xec1e8
cmpq %rax, %rbx
je 0x167d21
movq 0x8(%r14), %rax
movq $0x0, 0x20(%rax)
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
movq 0x18(%rax), %rsi
callq 0xeffd3
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rax), %rsi
callq 0xeffd3
movq %rax, (%rsp)
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movl $0x4e, %edx
callq 0x1092b2
movq %rax, %r15
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
movq 0x18(%rax), %rsi
callq 0xefce0
movq 0x8(%r14), %rcx
movq 0x8(%rcx), %rdi
movq 0x8(%rsp), %rcx
addq %rax, %rcx
decq %rcx
movq %r15, %rsi
movq %rax, %rdx
callq 0xed87b
movq (%rsp), %rdi
movq %r13, %rsi
movl $0x51, %edx
callq 0x1092b2
movq %rax, %r12
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rax), %rsi
callq 0xefce0
movq 0x8(%r14), %rcx
movq 0x8(%rcx), %rdi
movq (%rsp), %rcx
addq %rax, %rcx
decq %rcx
movq %r12, %rsi
movq %rax, %rdx
callq 0xed87b
movq 0x8(%rsp), %rbx
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
callq 0xf02da
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x11935c
movq %rax, %rbp
movq (%rsp), %rbx
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
callq 0xf02da
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x11935c
movq %rax, %rbx
movq 0x8(%r14), %rax
movq (%rax), %rdx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x18726c
movq %rax, %r13
movq 0x8(%r14), %rax
movb $0x0, 0x38(%rax)
testq %r13, %r13
je 0x167cdd
movq %r13, %rdi
callq 0x126c9b
movq 0x8(%r14), %rcx
cmpq 0x28(%rcx), %rax
jb 0x167cdd
movq %r13, %rdi
callq 0x126f96
movq 0x8(%r14), %rcx
cmpq 0x30(%rcx), %rax
jbe 0x167d2b
movq %r13, %rdi
callq 0x127c25
movq %rbp, %rdi
callq 0x1194b2
movq %rbx, %rdi
callq 0x1194b2
movq %r15, %rdi
leaq 0x228bd9(%rip), %r13    # 0x3908d8
movq %r13, %rsi
movl $0x5f, %edx
callq 0x109670
movq %r12, %rdi
movq %r13, %rsi
movl $0x60, %edx
callq 0x109670
jmp 0x167b54
movl $0x1, %eax
jmp 0x167e56
movq %r13, %rdi
callq 0x126c78
movq %rax, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq %r13, %rdi
callq 0x126cc7
movq %rax, 0x38(%rsp)
movq %rdx, 0x20(%rsp)
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
movq 0x18(%rax), %rdx
leaq 0x8(%rsp), %rsi
callq 0xf079f
movq %rax, 0x30(%rsp)
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rax), %rdx
movq %rsp, %rsi
callq 0xf079f
movq %rax, 0x28(%rsp)
movq 0x8(%r14), %rax
movq 0x18(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x20(%rax), %rax
movq %rax, 0x10(%rsp)
movq %r13, %rdi
callq 0x126c9b
movq %rax, %r14
movq %r13, %rdi
callq 0x126f96
subq $0x8, %rsp
leaq 0x26bad9(%rip), %rdi    # 0x3d3890
movq %rdi, %rsi
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %r14, %r8
movq %rax, %r9
pushq $0x0
pushq 0x30(%rsp)
pushq 0x58(%rsp)
pushq 0x58(%rsp)
pushq 0x70(%rsp)
callq 0x16811f
addq $0x30, %rsp
movq 0x50(%rsp), %r14
movq %rax, (%r14)
leaq 0x8(%rsp), %rcx
movq (%rcx), %rdx
movq %rax, %rdi
movq 0x30(%rsp), %rsi
callq 0x1656b7
movq (%r14), %rdi
movq %rsp, %rax
movq (%rax), %rdx
movq 0x28(%rsp), %rsi
callq 0x165701
movq %r13, %rdi
callq 0x127c25
movq %rbp, %rdi
callq 0x1194b2
movq %rbx, %rdi
callq 0x1194b2
leaq 0x228aa4(%rip), %rbx    # 0x3908d8
movq %r15, %rdi
movq %rbx, %rsi
movl $0x73, %edx
callq 0x109670
movq %r12, %rdi
movq %rbx, %rsi
movl $0x74, %edx
callq 0x109670
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4d4f8