// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/chseqids_stream.c
// Function: chseqids_stream_next
static int chseqids_stream_next(GtNodeStream *ns, GtGenomeNode **gn,
                                GtError *err)
{
  GtChseqidsStream *cs;
  GtGenomeNode *node, **gn_a, **gn_b;
  GtFeatureNode *feature_node;
  GtStr *changed_seqid;
  GtUword i;
  int GT_UNUSED rval, had_err = 0;
  gt_error_check(err);
  cs = chseqids_stream_cast(ns);

  if (!cs->sequence_regions_processed) {
    while (!had_err) {
      if (!(had_err = gt_node_stream_next(cs->in_stream, &node, err))) {
        if (node)
          gt_array_add(cs->node_buffer, node);
        else
          break;
        if (!gt_region_node_try_cast(node))
          break; /* no more sequence regions */
      }
    }
    /* now the buffer contains only sequence regions (except the last entry)
       -> change sequence ids */
    for (i = 0; !had_err && i < gt_array_size(cs->node_buffer); i++) {
      node = *(GtGenomeNode**) gt_array_get(cs->node_buffer, i);
      if (gt_genome_node_get_seqid(node)) {
        if  ((changed_seqid = gt_mapping_map_string(cs->chseqids_mapping,
                                     gt_str_get(gt_genome_node_get_seqid(node)),
                                                 err))) {
          if ((feature_node = gt_feature_node_try_cast(node))) {
            rval = gt_feature_node_traverse_children(feature_node,
                                                     changed_seqid,
                                                     change_sequence_id, true,
                                                     err);
            gt_assert(!rval); /* change_sequence_id() is sane */
          }
          else
            gt_genome_node_change_seqid(node, changed_seqid);
          gt_str_delete(changed_seqid);
        }
        else
          had_err = -1;
       }
    }
    /* sort them */
    if (!had_err)
      gt_genome_nodes_sort(cs->node_buffer);
    /* consolidate them */
    for (i = 1; !had_err && i + 1 < gt_array_size(cs->node_buffer); i++) {
      gn_a = gt_array_get(cs->node_buffer, i-1);
      gn_b = gt_array_get(cs->node_buffer, i);
      if (gt_genome_nodes_are_equal_region_nodes(*gn_a, *gn_b)) {
        gt_region_node_consolidate(gt_region_node_cast(*gn_b),
                                   gt_region_node_cast(*gn_a));
        gt_genome_node_delete(*gn_a);
        *gn_a = NULL;
      }
    }
    cs->sequence_regions_processed = true;
  }

  /* return non-null nodes from buffer */
  while (!had_err && cs->buffer_index < gt_array_size(cs->node_buffer)) {
    node = *(GtGenomeNode**) gt_array_get(cs->node_buffer, cs->buffer_index);
    cs->buffer_index++;
    if (node) {
      *gn = node;
      return had_err;
    }
  }

  if (!had_err)
    had_err = gt_node_stream_next(cs->in_stream, gn, err);
  if (!had_err && *gn) {
    if (gt_genome_node_get_seqid(*gn)) {
      changed_seqid = gt_mapping_map_string(cs->chseqids_mapping,
                                      gt_str_get(gt_genome_node_get_seqid(*gn)),
                                         err);
      gt_assert(changed_seqid); /* is always defined, because an undefined
                                   mapping would be catched earlier */
      if ((feature_node = gt_feature_node_try_cast(*gn))) {
        rval = gt_feature_node_traverse_children(feature_node, changed_seqid,
                                                 change_sequence_id, true, err);
        gt_assert(!rval); /* change_sequence_id() is sane */
      }
      else
        gt_genome_node_change_seqid(*gn, changed_seqid);
      gt_str_delete(changed_seqid);
    }
  }

  return had_err;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0x98(%rsp)
movq %rsi, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movl $0x0, 0x48(%rsp)
cmpq $0x0, 0x88(%rsp)
je 0x13980d
movq 0x88(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x1397d5
jmp 0x13980d
movq 0x5027c4(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3dc82d(%rip), %rsi    # 0x516013
leaq 0x3dc9d2(%rip), %rdx    # 0x5161bf
leaq 0x410d5a(%rip), %rcx    # 0x54a54e
leaq 0x410d19(%rip), %r8     # 0x54a514
movl $0x3c, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x13980f
callq 0x1396a0
movq %rax, %rdi
movq 0x98(%rsp), %rsi
callq 0x1b20f0
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rax
testb $0x1, 0x30(%rax)
jne 0x139b5d
jmp 0x139840
cmpl $0x0, 0x48(%rsp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x139850
jmp 0x1398b4
movq 0x80(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x88(%rsp), %rdx
leaq 0x78(%rsp), %rsi
callq 0x1b1d90
movl %eax, 0x48(%rsp)
cmpl $0x0, %eax
jne 0x1398b2
cmpq $0x0, 0x78(%rsp)
je 0x13989c
movq 0x80(%rsp), %rax
movq 0x20(%rax), %rdi
leaq 0x78(%rsp), %rsi
movl $0x8, %edx
callq 0x81100
jmp 0x13989e
jmp 0x1398b4
movq 0x78(%rsp), %rdi
callq 0x1ca8c0
cmpq $0x0, %rax
jne 0x1398b0
jmp 0x1398b4
jmp 0x1398b2
jmp 0x139840
movq $0x0, 0x50(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x47(%rsp)
jne 0x1398f7
movq 0x50(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x80(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x81370
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
setb %al
movb %al, 0x47(%rsp)
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0x139904
jmp 0x139a36
movq 0x80(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x50(%rsp), %rsi
callq 0x80b60
movq (%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
callq 0x171b70
cmpq $0x0, %rax
je 0x139a21
movq 0x80(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x78(%rsp), %rdi
callq 0x171b70
movq %rax, %rdi
callq 0x11dee0
movq 0x30(%rsp), %rdi
movq %rax, %rsi
movq 0x88(%rsp), %rdx
callq 0x1a5b90
movq %rax, 0x58(%rsp)
cmpq $0x0, %rax
je 0x139a17
movq 0x78(%rsp), %rdi
callq 0x170450
movq %rax, 0x60(%rsp)
cmpq $0x0, %rax
je 0x1399fc
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0x88(%rsp), %r8
leaq 0x5c5(%rip), %rdx       # 0x139f70
movl $0x1, %ecx
callq 0x16e2f0
movl %eax, 0x4c(%rsp)
cmpl $0x0, 0x4c(%rsp)
je 0x1399f8
movq 0x5025d9(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3dc642(%rip), %rsi    # 0x516013
leaq 0x3fa8b4(%rip), %rdx    # 0x53428c
leaq 0x410b6f(%rip), %rcx    # 0x54a54e
leaq 0x410b2e(%rip), %r8     # 0x54a514
movl $0x57, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1399fa
jmp 0x139a0b
movq 0x78(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x171f00
movq 0x58(%rsp), %rdi
callq 0x11f560
jmp 0x139a1f
movl $0xffffffff, 0x48(%rsp) # imm = 0xFFFFFFFF
jmp 0x139a21
jmp 0x139a23
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x1398bd
cmpl $0x0, 0x48(%rsp)
jne 0x139a4e
movq 0x80(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x1722f0
movq $0x1, 0x50(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x2f(%rsp)
jne 0x139a95
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
movq 0x80(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x81370
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
setb %al
movb %al, 0x2f(%rsp)
movb 0x2f(%rsp), %al
testb $0x1, %al
jne 0x139aa2
jmp 0x139b51
movq 0x80(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x50(%rsp), %rsi
subq $0x1, %rsi
callq 0x80b60
movq %rax, 0x70(%rsp)
movq 0x80(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x50(%rsp), %rsi
callq 0x80b60
movq %rax, 0x68(%rsp)
movq 0x70(%rsp), %rax
movq (%rax), %rdi
movq 0x68(%rsp), %rax
movq (%rax), %rsi
callq 0x172530
testb $0x1, %al
jne 0x139af7
jmp 0x139b3c
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x1ca710
movq %rax, 0x18(%rsp)
movq 0x70(%rsp), %rax
movq (%rax), %rdi
callq 0x1ca710
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x1ca730
movq 0x70(%rsp), %rax
movq (%rax), %rdi
callq 0x173180
movq 0x70(%rsp), %rax
movq $0x0, (%rax)
jmp 0x139b3e
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x139a57
movq 0x80(%rsp), %rax
movb $0x1, 0x30(%rax)
jmp 0x139b5f
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x17(%rsp)
jne 0x139ba0
movq 0x80(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x80(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x81370
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
setb %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x139baa
jmp 0x139c10
movq 0x80(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x80(%rsp), %rax
movq 0x28(%rax), %rsi
callq 0x80b60
movq (%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x80(%rsp), %rax
movq 0x28(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x28(%rax)
cmpq $0x0, 0x78(%rsp)
je 0x139c0b
movq 0x78(%rsp), %rcx
movq 0x90(%rsp), %rax
movq %rcx, (%rax)
movl 0x48(%rsp), %eax
movl %eax, 0xa4(%rsp)
jmp 0x139da7
jmp 0x139b5f
cmpl $0x0, 0x48(%rsp)
jne 0x139c3c
movq 0x80(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdx
callq 0x1b1d90
movl %eax, 0x48(%rsp)
cmpl $0x0, 0x48(%rsp)
jne 0x139d9c
movq 0x90(%rsp), %rax
cmpq $0x0, (%rax)
je 0x139d9c
movq 0x90(%rsp), %rax
movq (%rax), %rdi
callq 0x171b70
cmpq $0x0, %rax
je 0x139d9a
movq 0x80(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, (%rsp)
movq 0x90(%rsp), %rax
movq (%rax), %rdi
callq 0x171b70
movq %rax, %rdi
callq 0x11dee0
movq (%rsp), %rdi
movq %rax, %rsi
movq 0x88(%rsp), %rdx
callq 0x1a5b90
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x58(%rsp)
jne 0x139cf4
movq 0x5022dd(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3dc346(%rip), %rsi    # 0x516013
leaq 0x41088f(%rip), %rdx    # 0x54a563
leaq 0x410873(%rip), %rcx    # 0x54a54e
leaq 0x410832(%rip), %r8     # 0x54a514
movl $0x83, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x139cf6
movq 0x90(%rsp), %rax
movq (%rax), %rdi
callq 0x170450
movq %rax, 0x60(%rsp)
cmpq $0x0, %rax
je 0x139d7b
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0x88(%rsp), %r8
leaq 0x246(%rip), %rdx       # 0x139f70
movl $0x1, %ecx
callq 0x16e2f0
movl %eax, 0x4c(%rsp)
cmpl $0x0, 0x4c(%rsp)
je 0x139d77
movq 0x50225a(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3dc2c3(%rip), %rsi    # 0x516013
leaq 0x3fa535(%rip), %rdx    # 0x53428c
leaq 0x4107f0(%rip), %rcx    # 0x54a54e
leaq 0x4107af(%rip), %r8     # 0x54a514
movl $0x88, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x139d79
jmp 0x139d90
movq 0x90(%rsp), %rax
movq (%rax), %rdi
movq 0x58(%rsp), %rsi
callq 0x171f00
movq 0x58(%rsp), %rdi
callq 0x11f560
jmp 0x139d9c
movl 0x48(%rsp), %eax
movl %eax, 0xa4(%rsp)
movl 0xa4(%rsp), %eax
addq $0xa8, %rsp
retq
nopw %cs:(%rax,%rax)