// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4058, %rsp           # imm = 0x4058
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %rbx
testq %rdx, %rdx
je 0x211fee
movq %r13, %rdi
callq 0x101a9a
testb %al, %al
jne 0x212702
callq 0x211f58
movq %rax, %rdi
movq %rbx, %rsi
callq 0x16ae64
movq %rax, %r14
cmpb $0x1, 0x60(%rax)
jne 0x2120d5
movq 0x10(%r14), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x16ace8
movb $0x1, %bl
testl %eax, %eax
jne 0x212060
leaq 0x48(%rsp), %r15
movq (%r12), %rdi
testq %rdi, %rdi
je 0x212111
callq 0x14b5fc
movq %rax, 0x48(%rsp)
movq 0x18(%r14), %rdi
movl $0x8, %edx
movq %r15, %rsi
callq 0xd49ce
movq 0x10(%r14), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x16ace8
testl %eax, %eax
je 0x212025
movl %eax, %ebp
testb %bl, %bl
jne 0x2123aa
testl %ebp, %ebp
jne 0x212387
movq $0x0, 0x8(%rsp)
testq %r14, %r14
je 0x21270c
testq %r13, %r13
je 0x212099
movq %r13, %rdi
callq 0x101a9a
testb %al, %al
jne 0x212716
leaq 0x16f20a(%rip), %rdi    # 0x3812aa
callq 0x17950
movq 0x30(%r14), %r8
testq %rax, %rax
je 0x21216b
leaq 0x1b6e18(%rip), %rdx    # 0x3c8ed1
leaq 0x2050(%rsp), %rdi
movl $0x2000, %esi           # imm = 0x2000
movq %rax, %rcx
xorl %eax, %eax
callq 0x17c60
jmp 0x212189
movq 0x18(%r14), %rdi
movq 0x58(%r14), %rbx
callq 0xd4a9a
cmpq %rax, %rbx
jae 0x212104
movq 0x18(%r14), %rdi
movq 0x58(%r14), %rsi
callq 0xd47ba
movq (%rax), %rax
movq %rax, (%r12)
incq 0x58(%r14)
jmp 0x2123a8
movq $0x0, (%r12)
jmp 0x2123a8
testq %r14, %r14
je 0x212707
testq %r13, %r13
je 0x21212f
movq %r13, %rdi
callq 0x101a9a
testb %al, %al
jne 0x212711
movq 0x38(%r14), %rdi
leaq 0x18a8f7(%rip), %rsi    # 0x39ca31
movq %r13, %rdx
callq 0x103957
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x21215b
cmpq $0x0, 0x48(%r14)
je 0x2123be
movb $0x1, %al
jmp 0x21215d
xorl %eax, %eax
movq $0x0, 0x10(%rsp)
jmp 0x2123dd
leaq 0x1b6d62(%rip), %rdx    # 0x3c8ed4
leaq 0x2050(%rsp), %rdi
movl $0x2000, %esi           # imm = 0x2000
movq %r8, %rcx
xorl %eax, %eax
callq 0x17c60
leaq 0x151d39(%rip), %rsi    # 0x363ec9
leaq 0x2050(%rsp), %rdi
callq 0x17210
testq %rax, %rax
je 0x212371
movq %rax, %rbx
movq %rbx, %rdi
callq 0x17c20
cmpl $-0x1, %eax
jne 0x2121a9
movq %rbx, %rdi
callq 0x17a70
testq %rbx, %rbx
je 0x212371
movq %r12, %rbx
callq 0x12da06
movq %rax, %r12
movq 0x38(%r14), %rsi
movq %rax, %rdi
callq 0x12da6c
movq 0x30(%r14), %rsi
movq %r12, %rdi
callq 0x12dab6
movsd 0x80(%r14), %xmm0
ucomisd 0x13eb15(%rip), %xmm0   # 0x350d10
jne 0x2121ff
jnp 0x212207
movq %r12, %rdi
callq 0x12db00
cmpb $0x1, 0x61(%r14)
jne 0x21221d
leaq 0x17e1d1(%rip), %rsi    # 0x3903e6
movq %r12, %rdi
callq 0x12ddf0
movl 0x64(%r14), %esi
movl %esi, %eax
negl %eax
jo 0x21222f
movq %r12, %rdi
callq 0x12db53
movl 0x68(%r14), %esi
movl %esi, %eax
negl %eax
jo 0x212241
movq %r12, %rdi
callq 0x12db9b
movl 0x6c(%r14), %esi
movl %esi, %eax
negl %eax
jo 0x212253
movq %r12, %rdi
callq 0x12dbe3
movl 0x70(%r14), %esi
movl %esi, %eax
negl %eax
jo 0x212265
movq %r12, %rdi
callq 0x12dc2b
movl 0x74(%r14), %esi
movl %esi, %eax
negl %eax
jo 0x212277
movq %r12, %rdi
callq 0x12dc7e
movsd 0x90(%r14), %xmm0
ucomisd 0x13ea88(%rip), %xmm0   # 0x350d10
jne 0x21228c
jnp 0x2122bc
leaq 0x17e15e(%rip), %rdx    # 0x3903f1
leaq 0x50(%rsp), %rdi
movl $0x2000, %esi           # imm = 0x2000
movb $0x1, %al
callq 0x17c60
cmpl $0x2000, %eax           # imm = 0x2000
jae 0x21271b
leaq 0x50(%rsp), %rsi
movq %r12, %rdi
callq 0x12ddf0
movl 0x78(%r14), %esi
movl %esi, %eax
negl %eax
jo 0x2122ce
movq %r12, %rdi
callq 0x12dcd1
movsd 0x88(%r14), %xmm0
ucomisd 0x13ea31(%rip), %xmm0   # 0x350d10
jne 0x2122e3
jnp 0x2122eb
movq %r12, %rdi
callq 0x12dd19
movq 0xa0(%r14), %rcx
testq %rcx, %rcx
je 0x212327
leaq 0x1a22e8(%rip), %rdx    # 0x3b45e6
leaq 0x50(%rsp), %rdi
movl $0x2000, %esi           # imm = 0x2000
xorl %eax, %eax
callq 0x17c60
cmpl $0x2000, %eax           # imm = 0x2000
jae 0x212720
leaq 0x50(%rsp), %rsi
movq %r12, %rdi
callq 0x12ddf0
movq %r12, %rdi
movq %r13, %rsi
callq 0x165cfc
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x2126c3
movq %rax, %r15
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x165b56
testl %eax, %eax
movq %rbx, %r12
je 0x2126cb
leaq 0x1b6ba2(%rip), %rsi    # 0x3c8f07
movq %r13, %rdi
xorl %eax, %eax
callq 0x1019cf
jmp 0x212387
leaq 0x1b6ba5(%rip), %rsi    # 0x3c8f1d
movq %r13, %rdi
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %ebp, %ebp
jne 0x2123aa
movq 0x18(%r14), %rdi
movq 0x58(%r14), %rsi
callq 0xd47ba
movq (%rax), %rax
movq %rax, (%r12)
incq 0x58(%r14)
movb $0x0, 0x60(%r14)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x4058, %rsp           # imm = 0x4058
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xf36ef
movq 0x28(%r14), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0xf374b
movq %rax, 0x10(%rsp)
testq %rax, %rax
setne %al
testb %al, %al
je 0x212697
movq 0x18(%r14), %rdi
callq 0xd4a9a
testq %rax, %rax
je 0x2126b0
movq %r12, 0x30(%rsp)
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %r12d, %r12d
movq %r13, 0x20(%rsp)
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0xd47ba
movq (%rax), %rbx
movq %rbx, %rdi
callq 0x14aefc
testq %rax, %rax
je 0x212679
movq %rbx, %rdi
callq 0x14b1a8
movq %rax, %rbx
movq %rax, %rdi
callq 0x14b33e
movq %rax, %r13
movq %rax, %rdi
callq 0x14b89b
movq %rax, 0x28(%rsp)
movq %r13, %rdi
callq 0x14b8df
movq %rax, 0x50(%rsp)
movq %rdx, 0x58(%rsp)
cmpb $0x1, 0x62(%r14)
jne 0x21247d
movq %r13, %rdi
leaq 0x1b6a25(%rip), %rsi    # 0x3c8e94
callq 0x14918c
testq %rax, %rax
je 0x212690
movq %rbx, 0x38(%rsp)
movq %r15, 0x40(%rsp)
movq %r13, %rdi
leaq 0x1b668d(%rip), %rsi    # 0x3c8b1e
callq 0x14918c
movq %rax, %rbx
movq 0x28(%rsp), %rdi
callq 0x120d23
movq 0x50(%rsp), %r9
movq 0x58(%rsp), %r10
testq %rbx, %rbx
je 0x2124e2
subq $0x8, %rsp
movl $0x2000, %esi           # imm = 0x2000
leaq 0x2058(%rsp), %r15
movq %r15, %rdi
leaq 0x1b69ce(%rip), %rdx    # 0x3c8e9b
movq %rbx, %rcx
movq %rax, %r8
xorl %eax, %eax
pushq %r10
callq 0x17c60
addq $0x10, %rsp
jmp 0x212509
movl $0x2000, %esi           # imm = 0x2000
leaq 0x2050(%rsp), %r15
movq %r15, %rdi
leaq 0x1b69a5(%rip), %rdx    # 0x3c8e9e
movq %rax, %rcx
movq %r9, %r8
movq %r10, %r9
xorl %eax, %eax
callq 0x17c60
movq %r15, %rdi
movl $0x20, %esi
movl $0x2b, %edx
callq 0xe87ec
movq 0x20(%r14), %rbx
movq %r15, %rdi
callq 0xe8760
movq %rbx, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x105a4c
cmpq $0x0, 0x48(%r14)
je 0x2125b4
callq 0x1208f8
movq %rax, %r15
movq %r13, %rdi
callq 0x149bb2
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
movq 0x20(%rsp), %r13
pushq %r13
pushq 0x48(%r14)
callq 0x307764
addq $0x10, %rsp
movl %eax, %ebp
testl %eax, %eax
jne 0x2125a7
movq %r15, %rdi
callq 0x120d23
movq %rax, %rbx
movq %r15, %rdi
callq 0x120d4c
movl $0x32, %ecx
leaq 0x2050(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
movq 0x18(%rsp), %r8
callq 0x102ec0
movq %r15, %rdi
callq 0x121b03
jmp 0x212664
movq 0x28(%rsp), %rdi
callq 0x120d23
movq %rax, %rdi
leaq 0x186de7(%rip), %rsi    # 0x3993af
leaq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x177f0
leaq 0x50(%rsp), %rdi
callq 0x117813
leaq 0x1(%rax), %rdi
movl $0x1, %esi
leaq 0x1b6857(%rip), %rdx    # 0x3c8e45
movl $0x9b, %ecx
callq 0x1093ef
movq %rax, %r13
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0xefce0
leaq -0x1(%rax), %rcx
movq 0x50(%rsp), %rdx
addq %rcx, %rdx
addq 0x58(%rsp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
callq 0xed87b
leaq 0x50(%rsp), %rdi
callq 0x117813
movl $0x32, %ecx
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
movq 0x18(%rsp), %r8
callq 0x102ec0
movq %r13, %rdi
leaq 0x1b67f0(%rip), %rsi    # 0x3c8e45
movl $0xa1, %edx
callq 0x109670
movq 0x20(%rsp), %r13
movq 0x40(%rsp), %r15
incq %r15
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x14b3d0
incq %r12
movq 0x18(%r14), %rdi
callq 0xd4a9a
cmpq %rax, %r12
jb 0x212409
jmp 0x2126a3
movq 0x20(%rsp), %r13
jmp 0x212671
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movb $0x1, %bl
jmp 0x212062
testq %r15, %r15
sete %bl
movq 0x30(%rsp), %r12
jmp 0x2126b4
xorl %ebp, %ebp
movb $0x1, %bl
movq 0x18(%rsp), %rdi
callq 0x1040fc
jmp 0x212062
movq %rbx, %r12
jmp 0x212387
leaq 0x8(%rsp), %rbx
movq 0x8(%rsp), %rsi
movq %r14, %rdi
movq %r13, %rdx
callq 0x2129e9
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x165b56
testl %eax, %eax
je 0x2126d0
cmpl $0x1, %eax
jne 0x212387
xorl %ebp, %ebp
jmp 0x212387
callq 0x8245d
callq 0x825b1
callq 0x82578
callq 0x82496
callq 0x824cd
callq 0x82506
callq 0x8253f