// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/rdj-contigs-graph.c
// Function: gt_contigs_graph_simplify_from_contig
void gt_contigs_graph_simplify_from_contig(GtContigsGraph *cg,
    GtUword cnum, unsigned int incoming, bool restrict_rm_optionals)
{
  GtUword src = cnum;
  while (true)
  {
    GtContigsGraphSpmEdge *edge;
    if (cg->v_m[cnum].visited)
      break;
    cg->v_m[cnum].visited = true;
    if (cg->v_spm[incoming][cnum].deg == (uint64_t)1)
    {
      edge = gt_contigs_graph_find_only_spm_edge(cg, cnum, incoming);
      GT_CONTIGS_GRAPH_SET_DIR_MARK(cg, cnum, incoming);
      if (GT_CONTIGS_GRAPH_DIR_MARK_IS_UNSET(cg, edge->dest, incoming))
      {
        cnum = (GtUword)edge->dest;
        incoming = GT_CONTIGS_GRAPH_VALID_PATH_DIR(incoming, edge->reverse);
        /*gt_log_log("... continue from contig "GT_WU" (incoming=%u, deg=%u)",
                   cnum, incoming, cg->v_spm[incoming][cnum].deg);*/
      }
      else
      {
        break;
      }
    }
    else
    {
      if (gt_contigs_graph_nof_optional_neighbours(cg, cnum, incoming) ==
          cg->v_spm[incoming][cnum].deg - 1U)
      {
        if (restrict_rm_optionals && gt_contigs_graph_nof_optional_neighbours(
              cg, cnum, GT_CONTIGS_GRAPH_OTHER_DIR(incoming)) != cg->v_spm[
            incoming][cnum].deg - 1U)
        {
          break;
        }
        gt_contigs_graph_rm_optional_neighbours(cg, cnum, incoming);
        if (cg->v_spm[incoming][cnum].deg != (uint64_t)1)
        {
          GT_CONTIGS_GRAPH_SET_DIR_MARK(cg, cnum, incoming);
          break;
        }
        /*gt_log_log("... repeat contig "GT_WU" (incoming=%u, deg=%u)", cnum,
            incoming, cg->v_spm[incoming][cnum].deg);*/
      }
      else
      {
        break;
      }
    }
  }
  /* reset visited mark */
  cnum = src;
  while (true)
  {
    GtContigsGraphSpmEdge *edge;
    if (!cg->v_m[cnum].visited)
      break;
    cg->v_m[cnum].visited = false;
    if (cg->v_spm[incoming][cnum].deg != (uint64_t)1)
      break;
    edge = gt_contigs_graph_find_only_spm_edge(cg, cnum, incoming);
    cnum = (GtUword)edge->dest;
    incoming = GT_CONTIGS_GRAPH_VALID_PATH_DIR(incoming, edge->reverse);
  }
}

// Assembly:
subq $0x38, %rsp
movb %cl, %al
movq %rdi, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movl %edx, 0x24(%rsp)
andb $0x1, %al
movb %al, 0x23(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x28(%rsp), %rcx
movb (%rax,%rcx), %al
shrb $0x4, %al
andb $0x1, %al
testb $0x1, %al
je 0x27f7d3
jmp 0x27fa08
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x28(%rsp), %rcx
movb (%rax,%rcx), %dl
andb $-0x11, %dl
orb $0x10, %dl
movb %dl, (%rax,%rcx)
movq 0x30(%rsp), %rax
movl 0x24(%rsp), %ecx
movq 0x18(%rax,%rcx,8), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rax
andq $0xffff, %rax           # imm = 0xFFFF
cmpq $0x1, %rax
jne 0x27f8f5
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x24(%rsp), %edx
callq 0x27ed40
movq %rax, 0x10(%rsp)
cmpl $0x0, 0x24(%rsp)
jne 0x27f84f
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x28(%rsp), %rcx
movb (%rax,%rcx), %dl
andb $-0x41, %dl
orb $0x40, %dl
movb %dl, (%rax,%rcx)
jmp 0x27f869
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x28(%rsp), %rcx
movb (%rax,%rcx), %dl
andb $0x7f, %dl
orb $-0x80, %dl
movb %dl, (%rax,%rcx)
cmpl $0x0, 0x24(%rsp)
jne 0x27f88c
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rsp), %rcx
movl (%rcx), %ecx
movb (%rax,%rcx), %al
shrb $0x6, %al
andb $0x1, %al
testb $0x1, %al
je 0x27f8ad
cmpl $0x1, 0x24(%rsp)
jne 0x27f8eb
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rsp), %rcx
movl (%rcx), %ecx
movb (%rax,%rcx), %al
shrb $0x7, %al
testb $0x1, %al
jne 0x27f8eb
movq 0x10(%rsp), %rax
movl (%rax), %eax
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x24(%rsp)
setne %al
andb $0x1, %al
movzbl %al, %edx
movq 0x10(%rsp), %rax
movl 0x4(%rax), %eax
shrl $0x1d, %eax
andl $0x1, %eax
andb $0x1, %al
movzbl %al, %esi
movl $0x1, %eax
xorl %ecx, %ecx
cmpl %esi, %edx
cmovel %ecx, %eax
movl %eax, 0x24(%rsp)
jmp 0x27f8f0
jmp 0x27fa08
jmp 0x27fa03
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x24(%rsp), %edx
callq 0x27f550
movq 0x30(%rsp), %rcx
movl 0x24(%rsp), %edx
movq 0x18(%rcx,%rdx,8), %rcx
movq 0x28(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
andq $0xffff, %rcx           # imm = 0xFFFF
subl $0x1, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jne 0x27f9ff
testb $0x1, 0x23(%rsp)
je 0x27f988
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x24(%rsp), %ecx
xorl %edx, %edx
movl $0x1, %eax
cmpl $0x0, %ecx
cmovel %eax, %edx
callq 0x27f550
movq 0x30(%rsp), %rcx
movl 0x24(%rsp), %edx
movq 0x18(%rcx,%rdx,8), %rcx
movq 0x28(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
andq $0xffff, %rcx           # imm = 0xFFFF
subl $0x1, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
je 0x27f988
jmp 0x27fa08
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x24(%rsp), %edx
callq 0x27f640
movq 0x30(%rsp), %rax
movl 0x24(%rsp), %ecx
movq 0x18(%rax,%rcx,8), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rax
andq $0xffff, %rax           # imm = 0xFFFF
cmpq $0x1, %rax
je 0x27f9fd
cmpl $0x0, 0x24(%rsp)
jne 0x27f9e1
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x28(%rsp), %rcx
movb (%rax,%rcx), %dl
andb $-0x41, %dl
orb $0x40, %dl
movb %dl, (%rax,%rcx)
jmp 0x27f9fb
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x28(%rsp), %rcx
movb (%rax,%rcx), %dl
andb $0x7f, %dl
orb $-0x80, %dl
movb %dl, (%rax,%rcx)
jmp 0x27fa08
jmp 0x27fa01
jmp 0x27fa08
jmp 0x27fa03
jmp 0x27f7b4
movq 0x18(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x28(%rsp), %rcx
movb (%rax,%rcx), %al
shrb $0x4, %al
andb $0x1, %al
testb $0x1, %al
jne 0x27fa31
jmp 0x27fac9
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x28(%rsp), %rcx
movb (%rax,%rcx), %dl
andb $-0x11, %dl
orb $0x0, %dl
movb %dl, (%rax,%rcx)
movq 0x30(%rsp), %rax
movl 0x24(%rsp), %ecx
movq 0x18(%rax,%rcx,8), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rax
andq $0xffff, %rax           # imm = 0xFFFF
cmpq $0x1, %rax
je 0x27fa70
jmp 0x27fac9
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x24(%rsp), %edx
callq 0x27ed40
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movl (%rax), %eax
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x24(%rsp)
setne %al
andb $0x1, %al
movzbl %al, %edx
movq 0x8(%rsp), %rax
movl 0x4(%rax), %eax
shrl $0x1d, %eax
andl $0x1, %eax
andb $0x1, %al
movzbl %al, %esi
movl $0x1, %eax
xorl %ecx, %ecx
cmpl %esi, %edx
cmovel %ecx, %eax
movl %eax, 0x24(%rsp)
jmp 0x27fa12
addq $0x38, %rsp
retq
nop