// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/ltr/ltr_refseq_match_stream.c
// Function: gt_ltr_refseq_match_stream_next
static int gt_ltr_refseq_match_stream_next(GtNodeStream *ns, GtGenomeNode **gn,
                                           GtError *err)
{
  GtLTRRefseqMatchStream *rms;
  GtGenomeNode *ref_gn;
  int had_err = 0;
  GtUword n_to_check = 0;

  gt_error_check(err);
  rms = gt_ltr_refseq_match_stream_cast(ns);
  if (rms->first_next) {
    while (!(had_err = gt_node_stream_next(rms->in_stream, gn, err)) && *gn) {
      gt_assert(*gn && !had_err);
      ref_gn = gt_genome_node_ref(*gn);
      gt_array_add(rms->nodes, ref_gn);
    }
    if (!had_err)
      had_err = gt_ltr_refseq_match_stream_extract_sequences(rms, &n_to_check,
                                                             err);
    if (n_to_check > 0) {
      if (!had_err)
        had_err = gt_ltr_refseq_match_stream_refseq_match(rms, err);
      if (!had_err) {
        *gn = *(GtGenomeNode**) gt_array_get(rms->nodes, rms->next_index);
        rms->next_index++;
        rms->first_next = false;
        return 0;
      }
    }
  } else {
    if (rms->next_index >= gt_array_size(rms->nodes))
      *gn = NULL;
    else {
      *gn = *(GtGenomeNode**) gt_array_get(rms->nodes, rms->next_index);
      rms->next_index++;
    }
    return 0;
  }

  return had_err;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movl $0x0, 0x24(%rsp)
movq $0x0, 0x18(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x300e94
movq 0x38(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x300e5c
jmp 0x300e94
movq 0x33b13d(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2151a6(%rip), %rsi    # 0x516013
leaq 0x21534b(%rip), %rdx    # 0x5161bf
leaq 0x291ac0(%rip), %rcx    # 0x59293b
leaq 0x291ad9(%rip), %r8     # 0x59295b
movl $0x16d, %r9d            # imm = 0x16D
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x300e96
callq 0x300d90
movq %rax, %rdi
movq 0x48(%rsp), %rsi
callq 0x1b20f0
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
testb $0x1, 0x60(%rax)
je 0x301013
jmp 0x300ebe
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x40(%rsp), %rsi
movq 0x38(%rsp), %rdx
callq 0x1b1d90
movl %eax, %ecx
movl %ecx, 0x24(%rsp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x17(%rsp)
jne 0x300ef7
movq 0x40(%rsp), %rax
cmpq $0x0, (%rax)
setne %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x300f01
jmp 0x300f7e
jmp 0x300f03
movq 0x40(%rsp), %rax
cmpq $0x0, (%rax)
je 0x300f15
cmpl $0x0, 0x24(%rsp)
je 0x300f4d
movq 0x33b084(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2150ed(%rip), %rsi    # 0x516013
leaq 0x24bcd3(%rip), %rdx    # 0x54cc00
leaq 0x291a07(%rip), %rcx    # 0x59293b
leaq 0x291a20(%rip), %r8     # 0x59295b
movl $0x171, %r9d            # imm = 0x171
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x300f4f
movq 0x40(%rsp), %rax
movq (%rax), %rdi
callq 0x171410
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rdi
leaq 0x28(%rsp), %rsi
movl $0x8, %edx
callq 0x81100
jmp 0x300ebe
cmpl $0x0, 0x24(%rsp)
jne 0x300f9d
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rdx
leaq 0x18(%rsp), %rsi
callq 0x301590
movl %eax, 0x24(%rsp)
cmpq $0x0, 0x18(%rsp)
jbe 0x301011
cmpl $0x0, 0x24(%rsp)
jne 0x300fbf
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x301bb0
movl %eax, 0x24(%rsp)
cmpl $0x0, 0x24(%rsp)
jne 0x30100f
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x58(%rax), %rsi
callq 0x80b60
movq (%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, (%rax)
movq 0x30(%rsp), %rax
movq 0x58(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x58(%rax)
movq 0x30(%rsp), %rax
movb $0x0, 0x60(%rax)
movl $0x0, 0x54(%rsp)
jmp 0x30108f
jmp 0x301011
jmp 0x301087
movq 0x30(%rsp), %rax
movq 0x58(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x81370
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jb 0x30104a
movq 0x40(%rsp), %rax
movq $0x0, (%rax)
jmp 0x30107d
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x58(%rax), %rsi
callq 0x80b60
movq (%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, (%rax)
movq 0x30(%rsp), %rax
movq 0x58(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x58(%rax)
movl $0x0, 0x54(%rsp)
jmp 0x30108f
movl 0x24(%rsp), %eax
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax,%rax)