// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/snp_annotator_stream.c
// Function: snp_annotator_stream_next
static int snp_annotator_stream_next(GtNodeStream *ns, GtGenomeNode **gn,
                                     GtError *err)
{
  GtSNPAnnotatorStream *sas;
  int had_err = 0;
  bool complete_cluster = false;
  GtGenomeNode *mygn = NULL;
  GtFeatureNode *fn = NULL;
  const char *snv_type = gt_symbol(gt_ft_SNV),
             *snp_type = gt_symbol(gt_ft_SNP),
             *gene_type = gt_symbol(gt_ft_gene);
  gt_error_check(err);
  sas = gt_snp_annotator_stream_cast(ns);

  /* if there are still SNPs left in the buffer, output them */
  if (gt_queue_size(sas->outqueue) > 0) {
    *gn = (GtGenomeNode*) gt_queue_get(sas->outqueue);
    return had_err;
  } else complete_cluster = false;

  while (!had_err && !complete_cluster) {
    had_err = gt_node_stream_next(sas->merge_stream, &mygn, err);

    /* stop if stream is at the end */
    if (had_err || !mygn) break;

    /* process all feature nodes */
    if ((fn = gt_feature_node_try_cast(mygn))) {
      GtGenomeNode *addgn;
      const char *type = gt_feature_node_get_type(fn);
      GtRange new_rng = gt_genome_node_get_range(mygn);
      if (type == snv_type || type == snp_type) {
        /* -----> this is a SNP <----- */
        if (gt_range_overlap(&new_rng, &sas->cur_gene_range)) {
          /* it falls into the currently observed range */
          gt_queue_add(sas->snps, gt_genome_node_ref((GtGenomeNode*) fn));
        } else {
          /* SNP outside a gene, this cluster is done
             add to out queue and start serving */
          gt_assert(gt_queue_size(sas->outqueue) == 0);
          had_err = snp_annotator_stream_process_current_gene(sas, err);
          gt_queue_add(sas->outqueue, mygn);
          if (gt_queue_size(sas->outqueue) > 0) {
            *gn = (GtGenomeNode*) gt_queue_get(sas->outqueue);
            complete_cluster = true;
          }
        }
      } else if (type == gene_type) {
        /* -----> this is a gene <----- */
        if (gt_array_size(sas->cur_gene_set) == 0UL) {
          /* new overlapping gene cluster */
          addgn = gt_genome_node_ref(mygn);
          gt_array_add(sas->cur_gene_set, addgn);
          sas->cur_gene_range = gt_genome_node_get_range(mygn);
        } else {
          if (gt_range_overlap(&new_rng, &sas->cur_gene_range)) {
            /* gene overlaps with current one, add to cluster */
            addgn = gt_genome_node_ref(mygn);
            gt_array_add(sas->cur_gene_set, addgn);
            sas->cur_gene_range = gt_range_join(&sas->cur_gene_range, &new_rng);
          } else {
            /* finish current cluster and start a new one */
            had_err = snp_annotator_stream_process_current_gene(sas, err);
            if (!had_err) {
              addgn = gt_genome_node_ref(mygn);
              gt_array_add(sas->cur_gene_set, addgn);
              sas->cur_gene_range = gt_genome_node_get_range(mygn);
            }
            if (gt_queue_size(sas->outqueue) > 0) {
              *gn = (GtGenomeNode*) gt_queue_get(sas->outqueue);
              complete_cluster = true;
            }
          }
        }
        /* from now on, genes are kept in gene cluster arrays only */
        gt_genome_node_delete(mygn);
      }
    } else {
      /* meta node */
      had_err = snp_annotator_stream_process_current_gene(sas, err);
      if (!had_err) {
        gt_queue_add(sas->outqueue, mygn);
      }
      if (gt_queue_size(sas->outqueue) > 0) {
        *gn = (GtGenomeNode*) gt_queue_get(sas->outqueue);
        complete_cluster = true;
      }
    }
  }

  return had_err;
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xc8(%rsp)
movq %rsi, 0xc0(%rsp)
movq %rdx, 0xb8(%rsp)
movl $0x0, 0xac(%rsp)
movb $0x0, 0xab(%rsp)
movq $0x0, 0xa0(%rsp)
movq $0x0, 0x98(%rsp)
leaq 0x38d9df(%rip), %rdi    # 0x565b80
callq 0x120930
movq %rax, 0x90(%rsp)
leaq 0x38d9cf(%rip), %rdi    # 0x565b84
callq 0x120930
movq %rax, 0x88(%rsp)
leaq 0x3da99d(%rip), %rdi    # 0x5b2b66
callq 0x120930
movq %rax, 0x80(%rsp)
cmpq $0x0, 0xb8(%rsp)
je 0x1d822c
movq 0xb8(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x1d81f4
jmp 0x1d822c
movq 0x463da5(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x33de0e(%rip), %rsi    # 0x516013
leaq 0x33dfb3(%rip), %rdx    # 0x5161bf
leaq 0x38d975(%rip), %rcx    # 0x565b88
leaq 0x38d942(%rip), %r8     # 0x565b5c
movl $0x76, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1d822e
callq 0x1d7f80
movq %rax, %rdi
movq 0xc8(%rsp), %rsi
callq 0x1b20f0
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
movq 0x50(%rax), %rdi
callq 0xfd4d0
cmpq $0x0, %rax
jbe 0x1d8294
movq 0xb0(%rsp), %rax
movq 0x50(%rax), %rdi
callq 0xfd3f0
movq %rax, %rcx
movq 0xc0(%rsp), %rax
movq %rcx, (%rax)
movl 0xac(%rsp), %eax
movl %eax, 0xd4(%rsp)
jmp 0x1d8732
movb $0x0, 0xab(%rsp)
jmp 0x1d829e
xorl %eax, %eax
cmpl $0x0, 0xac(%rsp)
movb %al, 0x2f(%rsp)
jne 0x1d82bb
movb 0xab(%rsp), %al
xorb $-0x1, %al
movb %al, 0x2f(%rsp)
movb 0x2f(%rsp), %al
testb $0x1, %al
jne 0x1d82c8
jmp 0x1d8724
movq 0xb0(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0xb8(%rsp), %rdx
leaq 0xa0(%rsp), %rsi
callq 0x1b1d90
movl %eax, 0xac(%rsp)
cmpl $0x0, 0xac(%rsp)
jne 0x1d8305
cmpq $0x0, 0xa0(%rsp)
jne 0x1d830a
jmp 0x1d8724
movq 0xa0(%rsp), %rdi
callq 0x170450
movq %rax, 0x98(%rsp)
cmpq $0x0, %rax
je 0x1d86a0
movq 0x98(%rsp), %rdi
callq 0x16d430
movq %rax, 0x70(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x171cc0
movq %rax, 0x60(%rsp)
movq %rdx, 0x68(%rsp)
movq 0x70(%rsp), %rax
cmpq 0x90(%rsp), %rax
je 0x1d8374
movq 0x70(%rsp), %rax
cmpq 0x88(%rsp), %rax
jne 0x1d848d
movq 0xb0(%rsp), %rsi
addq $0x30, %rsi
leaq 0x60(%rsp), %rdi
callq 0x107390
testb $0x1, %al
jne 0x1d8390
jmp 0x1d83c0
movq 0xb0(%rsp), %rax
movq 0x48(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x98(%rsp), %rdi
callq 0x171410
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0xfd170
jmp 0x1d8488
jmp 0x1d83c2
movq 0xb0(%rsp), %rax
movq 0x50(%rax), %rdi
callq 0xfd4d0
cmpq $0x0, %rax
je 0x1d8411
movq 0x463bc0(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x33dc29(%rip), %rsi    # 0x516013
leaq 0x38d7b1(%rip), %rdx    # 0x565ba2
leaq 0x38d790(%rip), %rcx    # 0x565b88
leaq 0x38d75d(%rip), %r8     # 0x565b5c
movl $0x92, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1d8413
movq 0xb0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
callq 0x1d88e0
movl %eax, 0xac(%rsp)
movq 0xb0(%rsp), %rax
movq 0x50(%rax), %rdi
movq 0xa0(%rsp), %rsi
callq 0xfd170
movq 0xb0(%rsp), %rax
movq 0x50(%rax), %rdi
callq 0xfd4d0
cmpq $0x0, %rax
jbe 0x1d8486
movq 0xb0(%rsp), %rax
movq 0x50(%rax), %rdi
callq 0xfd3f0
movq %rax, %rcx
movq 0xc0(%rsp), %rax
movq %rcx, (%rax)
movb $0x1, 0xab(%rsp)
jmp 0x1d8488
jmp 0x1d869e
movq 0x70(%rsp), %rax
cmpq 0x80(%rsp), %rax
jne 0x1d869c
movq 0xb0(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x81370
cmpq $0x0, %rax
jne 0x1d8527
movq 0xa0(%rsp), %rdi
callq 0x171410
movq %rax, 0x78(%rsp)
movq 0xb0(%rsp), %rax
movq 0x20(%rax), %rdi
leaq 0x78(%rsp), %rsi
movl $0x8, %edx
callq 0x81100
movq 0xb0(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x171cc0
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x50(%rsp)
movq %rdx, 0x58(%rsp)
movq 0x50(%rsp), %rcx
movq %rcx, 0x30(%rax)
movq 0x58(%rsp), %rcx
movq %rcx, 0x38(%rax)
jmp 0x1d868f
movq 0xb0(%rsp), %rsi
addq $0x30, %rsi
leaq 0x60(%rsp), %rdi
callq 0x107390
testb $0x1, %al
jne 0x1d8543
jmp 0x1d85bc
movq 0xa0(%rsp), %rdi
callq 0x171410
movq %rax, 0x78(%rsp)
movq 0xb0(%rsp), %rax
movq 0x20(%rax), %rdi
leaq 0x78(%rsp), %rsi
movl $0x8, %edx
callq 0x81100
movq 0xb0(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xb0(%rsp), %rdi
addq $0x30, %rdi
leaq 0x60(%rsp), %rsi
callq 0x107730
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x40(%rsp)
movq %rdx, 0x48(%rsp)
movq 0x40(%rsp), %rcx
movq %rcx, 0x30(%rax)
movq 0x48(%rsp), %rcx
movq %rcx, 0x38(%rax)
jmp 0x1d868d
movq 0xb0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
callq 0x1d88e0
movl %eax, 0xac(%rsp)
cmpl $0x0, 0xac(%rsp)
jne 0x1d864d
movq 0xa0(%rsp), %rdi
callq 0x171410
movq %rax, 0x78(%rsp)
movq 0xb0(%rsp), %rax
movq 0x20(%rax), %rdi
leaq 0x78(%rsp), %rsi
movl $0x8, %edx
callq 0x81100
movq 0xb0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x171cc0
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
movq 0x30(%rsp), %rcx
movq %rcx, 0x30(%rax)
movq 0x38(%rsp), %rcx
movq %rcx, 0x38(%rax)
movq 0xb0(%rsp), %rax
movq 0x50(%rax), %rdi
callq 0xfd4d0
cmpq $0x0, %rax
jbe 0x1d868b
movq 0xb0(%rsp), %rax
movq 0x50(%rax), %rdi
callq 0xfd3f0
movq %rax, %rcx
movq 0xc0(%rsp), %rax
movq %rcx, (%rax)
movb $0x1, 0xab(%rsp)
jmp 0x1d868d
jmp 0x1d868f
movq 0xa0(%rsp), %rdi
callq 0x173180
jmp 0x1d869e
jmp 0x1d871f
movq 0xb0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
callq 0x1d88e0
movl %eax, 0xac(%rsp)
cmpl $0x0, 0xac(%rsp)
jne 0x1d86df
movq 0xb0(%rsp), %rax
movq 0x50(%rax), %rdi
movq 0xa0(%rsp), %rsi
callq 0xfd170
movq 0xb0(%rsp), %rax
movq 0x50(%rax), %rdi
callq 0xfd4d0
cmpq $0x0, %rax
jbe 0x1d871d
movq 0xb0(%rsp), %rax
movq 0x50(%rax), %rdi
callq 0xfd3f0
movq %rax, %rcx
movq 0xc0(%rsp), %rax
movq %rcx, (%rax)
movb $0x1, 0xab(%rsp)
jmp 0x1d871f
jmp 0x1d829e
movl 0xac(%rsp), %eax
movl %eax, 0xd4(%rsp)
movl 0xd4(%rsp), %eax
addq $0xd8, %rsp
retq
nopw %cs:(%rax,%rax)