// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/rdj-contigs-graph.c
// Function: gt_contigs_graph_show_dot_for_contig
static void gt_contigs_graph_show_dot_for_contig(GtContigsGraph *cg,
    GtUword cnum, GtFile *outfp)
{
  unsigned int incoming;
  GtContigsGraphSpmEdge *edge;
  for (incoming = 0; incoming < 2U; incoming++)
  {
    for (GT_CONTIGS_GRAPH_EACH_SPM_EDGE(cg, cnum, incoming, edge))
    {
      if (!cg->v_m[edge->dest].processed)
      {
        if (cg->dot_show_deleted || !edge->deleted)
          gt_file_xprintf(outfp, "  "GT_WU" -- "GT_WU" "
              "[dir=both,arrowtail=%s,arrowhead=%s%s];\n", cnum,
              (GtUword)edge->dest,
              incoming ? "normal" : "inv",
              ((incoming && edge->reverse) ||
               (!incoming && !edge->reverse)) ? "normal" : "inv",
              edge->deleted ? ",style=dotted" : "");
      }
    }
  }
  if (cg->dot_show_deleted || !cg->v_m[cnum].deleted)
    gt_contigs_graph_show_dot_vertex(cg, cnum, outfp);
}

void gt_contigs_graph_show_dot(GtContigsGraph *cg, GtFile *outfp)
{
  GtUword cnum;
  gt_assert(cg != NULL);
  gt_file_xprintf(outfp, GT_CONTIGS_GRAPH_DOT_HEADER);
  for (cnum = 0; cnum < cg->nof_v; cnum++)
  {
    cg->v_m[cnum].processed = false;
  }
  for (cnum = 0; cnum < cg->nof_v; cnum++)
  {
    gt_contigs_graph_show_dot_for_contig(cg, cnum, outfp);
    cg->v_m[cnum].processed = true;
  }
  gt_file_xprintf(outfp, GT_CONTIGS_GRAPH_DOT_FOOTER);
}

GtContigsGraphSpmEdge* gt_contigs_graph_find_only_spm_edge(GtContigsGraph *cg,
    GtUword cnum, unsigned int incoming)
{
  GtContigsGraphSpmEdge *edge;
  gt_log_log("find_only_spm_edge(cnum="GT_WU",incoming=%u)",cnum,incoming);
  for (GT_CONTIGS_GRAPH_EACH_SPM_EDGE(cg, cnum, incoming, edge))
  {
    if (!edge->deleted)
      return edge;
  }
  gt_assert(false);
  return NULL;
}

GtContigsGraphSpmEdge* gt_contigs_graph_find_spm_edge(GtContigsGraph *cg,
    GtUword cnum, unsigned int incoming, GtUword dest)
{
  GtContigsGraphSpmEdge *edge;
  gt_log_log("find_spm_edge(cnum="GT_WU",incoming=%u,dest="GT_WU")",
             cnum,incoming,dest);
  for (GT_CONTIGS_GRAPH_EACH_SPM_EDGE(cg, cnum, incoming, edge))
  {
    if (edge->deleted)
      continue;
    if (edge->dest == (uint64_t)dest)
      return edge;
  }
  gt_assert(false);
  return NULL;
}

GtContigsGraphSpmEdge* gt_contigs_graph_find_deleted_spm_edge(
    GtContigsGraph *cg, GtUword cnum, unsigned int incoming)
{
  GtContigsGraphSpmEdge *edge;
  gt_log_log("find_deleted_spm_edge(cnum="GT_WU",incoming=%u)",cnum,incoming);
  gt_assert(cg->v_spm[incoming][cnum + 1UL].ptr >
      cg->v_spm[incoming][cnum].ptr + cg->v_spm[incoming][cnum].deg);
  for (GT_CONTIGS_GRAPH_EACH_SPM_EDGE(cg, cnum, incoming, edge))
  {
    if (edge->deleted)
      return edge;
  }
  gt_assert(false);
  return NULL;
}

void gt_contigs_graph_rm_spm_edge(GtContigsGraph *cg,
    GtUword cnum, unsigned int incoming, GtContigsGraphSpmEdge *edge)
{
  GtContigsGraphSpmEdge *reverse_edge;
  unsigned int reverse_incoming;
  gt_log_log("rm spm edge "GT_WU" -- "GT_WU"", cnum, (GtUword)edge->dest);
  for (reverse_incoming = 0; reverse_incoming < 2U; reverse_incoming++)
  {
    for (GT_CONTIGS_GRAPH_EACH_SPM_EDGE(cg, edge->dest,
          reverse_incoming, reverse_edge))
    {
      if (reverse_edge->deleted)
        continue;
      if ((GtUword)reverse_edge->dest == cnum &&
          (reverse_edge->reverse == (incoming == reverse_incoming)))
      {
        gt_assert(cg->v_spm[incoming][cnum].deg > 0);
        (cg->v_spm[incoming][cnum].deg)--;
        edge->deleted = true;

        gt_assert(cg->v_spm[reverse_incoming][edge->dest].deg > 0);
        (cg->v_spm[reverse_incoming][edge->dest].deg)--;
        reverse_edge->deleted = true;
        return;
      }
    }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
cmpl $0x2, 0x3c(%rsp)
jae 0x27ed02
movq 0x50(%rsp), %rax
movl 0x3c(%rsp), %ecx
movq 0x80(%rax,%rcx,8), %rax
movq 0x50(%rsp), %rcx
movl 0x3c(%rsp), %edx
movq 0x18(%rcx,%rdx,8), %rcx
movq 0x48(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x10, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x50(%rsp), %rcx
movl 0x3c(%rsp), %edx
movq 0x80(%rcx,%rdx,8), %rcx
movq 0x50(%rsp), %rdx
movl 0x3c(%rsp), %esi
movq 0x18(%rdx,%rsi,8), %rdx
movq 0x48(%rsp), %rsi
movq 0x8(%rdx,%rsi,8), %rdx
shrq $0x10, %rdx
shlq $0x3, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x27ecf0
movq 0x50(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x30(%rsp), %rcx
movl (%rcx), %ecx
movb (%rax,%rcx), %al
shrb $0x3, %al
andb $0x1, %al
testb $0x1, %al
jne 0x27ecdb
movq 0x50(%rsp), %rax
testb $0x1, 0xa8(%rax)
jne 0x27ebe7
movq 0x30(%rsp), %rax
movl 0x4(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
testl $0x1, %eax
jne 0x27ecd9
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
movl (%rax), %eax
movq %rax, 0x20(%rsp)
movl 0x3c(%rsp), %edx
leaq 0x301d41(%rip), %rax    # 0x580953
leaq 0x301d33(%rip), %rcx    # 0x58094c
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x3c(%rsp)
je 0x27ec48
movq 0x30(%rsp), %rax
movl 0x4(%rax), %ecx
shrl $0x1d, %ecx
andl $0x1, %ecx
movb $0x1, %al
testl $0x1, %ecx
movb %al, 0xf(%rsp)
jne 0x27ec71
xorl %eax, %eax
cmpl $0x0, 0x3c(%rsp)
movb %al, 0xe(%rsp)
jne 0x27ec69
movq 0x30(%rsp), %rax
movl 0x4(%rax), %eax
shrl $0x1d, %eax
andl $0x1, %eax
xorb $-0x1, %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
movb %al, 0xf(%rsp)
movq 0x28(%rsp), %r8
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rdi
movb 0xf(%rsp), %sil
leaq 0x301cc2(%rip), %r9     # 0x580953
leaq 0x301cb4(%rip), %rax    # 0x58094c
testb $0x1, %sil
cmovneq %rax, %r9
movq 0x30(%rsp), %rax
movl 0x4(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
movb %al, %r10b
leaq 0x31e970(%rip), %rax    # 0x59d628
leaq 0x301c98(%rip), %rsi    # 0x580957
testb $0x1, %r10b
cmovneq %rsi, %rax
leaq 0x301c48(%rip), %rsi    # 0x580916
movq %rax, (%rsp)
movb $0x0, %al
callq 0xddca0
jmp 0x27ecdb
jmp 0x27ecdd
movq 0x30(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x30(%rsp)
jmp 0x27eb5e
jmp 0x27ecf2
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x27eb1b
movq 0x50(%rsp), %rax
testb $0x1, 0xa8(%rax)
jne 0x27ed27
movq 0x50(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x48(%rsp), %rcx
movb (%rax,%rcx), %al
andb $0x1, %al
testb $0x1, %al
jne 0x27ed3b
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x281920
addq $0x58, %rsp
retq