// File: /workspace/github_c_makefile_star2_O3/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 0x1600a5
testq %rsi, %rsi
je 0x1600a5
movq %rdi, %rbx
movq %rsi, 0x40(%rsp)
movq 0x35ea55(%rip), %rdi    # 0x4be7b0
testq %rdi, %rdi
jne 0x15fd82
leaq -0x3b(%rip), %rsi       # 0x15fd2c
leaq 0x33c(%rip), %rdx       # 0x1600aa
movl $0x10, %edi
callq 0x15ddd4
movq %rax, %rdi
movq %rax, 0x35ea2e(%rip)    # 0x4be7b0
movq %rbx, %rsi
callq 0x15de4d
movq %rax, %r14
leaq 0x22776b(%rip), %r12    # 0x3874ff
movq 0x8(%r14), %rax
movq 0x20(%rax), %rbx
cmpb $0x0, 0x38(%rax)
jne 0x15fda9
incq %rbx
movq %rbx, 0x20(%rax)
movq 0x10(%rax), %rdi
callq 0xe7bac
movq 0x8(%r14), %rcx
cmpq %rax, %rbx
jne 0x15fde4
movq 0x8(%rcx), %rdi
movq 0x18(%rcx), %rbx
incq %rbx
movq %rbx, 0x18(%rcx)
callq 0xe7bac
cmpq %rax, %rbx
je 0x15ff56
movq 0x8(%r14), %rcx
movq $0x0, 0x20(%rcx)
movq 0x8(%rcx), %rdi
movq 0x18(%rcx), %rsi
callq 0xeb9d2
movq %rax, %r13
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rax), %rsi
callq 0xeb9d2
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
movl $0x4e, %edx
callq 0x104226
movq %rax, %rbx
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
movq 0x18(%rax), %rsi
callq 0xeb6ee
movq 0x8(%r14), %rcx
movq 0x8(%rcx), %rdi
leaq (%rax,%r13), %rcx
decq %rcx
movq %rbx, %rsi
movq %rax, %rdx
callq 0xe92be
movq %r15, %rdi
movq %r12, %rsi
movl $0x51, %edx
callq 0x104226
movq %rax, %r12
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rax), %rsi
callq 0xeb6ee
movq 0x8(%r14), %rcx
movq 0x8(%rcx), %rdi
leaq (%rax,%r15), %rcx
decq %rcx
movq %r12, %rsi
movq %rax, %rdx
callq 0xe92be
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
callq 0xebcd9
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x113c84
movq %rax, %rbp
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
callq 0xebcd9
movq %r12, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x113c84
movq %rax, %rbx
movq 0x8(%r14), %rax
movq (%rax), %rdx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x17eba0
movq %rax, %r12
movq 0x8(%r14), %rax
movb $0x0, 0x38(%rax)
testq %r12, %r12
je 0x15ff0f
movq %r12, %rdi
callq 0x120ea3
movq 0x8(%r14), %rcx
cmpq 0x28(%rcx), %rax
jb 0x15ff0f
movq %r12, %rdi
callq 0x12119e
movq 0x8(%r14), %rcx
cmpq 0x30(%rcx), %rax
jbe 0x15ff60
movq %r12, %rdi
callq 0x121e3c
movq %rbp, %rdi
callq 0x113ddc
movq %rbx, %rdi
callq 0x113ddc
movq 0x8(%rsp), %rdi
leaq 0x2275cc(%rip), %r12    # 0x3874ff
movq %r12, %rsi
movl $0x5f, %edx
callq 0x1045eb
movq (%rsp), %rdi
movq %r12, %rsi
movl $0x60, %edx
callq 0x1045eb
jmp 0x15fd94
movl $0x1, %eax
jmp 0x160096
leaq 0x50(%rsp), %rax
movq %r13, (%rax)
movq %rax, %r13
leaq 0x48(%rsp), %rax
movq %r15, (%rax)
movq %rax, %r15
movq %r12, %rdi
callq 0x120e80
movq %rax, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %r12, %rdi
callq 0x120ecf
movq %rax, 0x28(%rsp)
movq %rdx, 0x10(%rsp)
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
movq 0x18(%rax), %rdx
movq %r13, %rsi
callq 0xec19e
movq %rax, 0x20(%rsp)
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rax), %rdx
movq %r15, %rsi
callq 0xec19e
movq %rax, 0x18(%rsp)
movq 0x8(%r14), %rax
movq 0x18(%rax), %r14
movq 0x20(%rax), %r15
movq %r12, %rdi
callq 0x120ea3
movq %rax, %r13
movq %r12, %rdi
callq 0x12119e
subq $0x8, %rsp
leaq 0x26a17a(%rip), %rdi    # 0x3ca170
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 0x16035f
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 0x15d987
movq (%r14), %rdi
leaq 0x48(%rsp), %rax
movq (%rax), %rdx
movq 0x18(%rsp), %rsi
callq 0x15d9d4
movq %r12, %rdi
callq 0x121e3c
movq %rbp, %rdi
callq 0x113ddc
movq %rbx, %rdi
callq 0x113ddc
leaq 0x22748e(%rip), %rbx    # 0x3874ff
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movl $0x73, %edx
callq 0x1045eb
movq (%rsp), %rdi
movq %rbx, %rsi
movl $0x74, %edx
callq 0x1045eb
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4c675