// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/rbtree.c
// Function: gt_rbtree_erase
int gt_rbtree_erase(GtRBTree *tree, void *key)
{
  int rv = -1;
  gt_assert(tree);
  gt_assert(key);
  if (tree->root != NULL) {
    GtRBTreeNode head = {0,0,{NULL, NULL}}; /* False tree root */
    GtRBTreeNode *q, *p, *g; /* Helpers */
    GtRBTreeNode *f = NULL;  /* Found item */
    int dir = 1;

    /* Set up our helpers */
    q = &head;
    p = NULL;
    q->link[1] = tree->root;

    /* Search and push a red node down to fix red violations as we go */
    while (q->link[dir] != NULL) {
      int last = dir;

      /* Move the helpers down */
      g = p, p = q;
      q = q->link[dir];
      dir = (int) (tree->cmp(q->key, key, tree->info) < 0);

      /* Save the node with matching key and keep going; we'll do removal
         tasks at the end */
      if (tree->cmp(q->key, key, tree->info) == 0)
        f = q;

      /* Push the red node down with rotations and color flips */
      if (!GT_RBTREE_NODE_IS_RED(q)
            && !GT_RBTREE_NODE_IS_RED(q->link[dir])) {
        if (GT_RBTREE_NODE_IS_RED(q->link[(int) !dir])) {
          p = p->link[last] = gt_rbtree_single(q, dir);
        } else if (!GT_RBTREE_NODE_IS_RED(q->link[(int) !dir])) {
          GtRBTreeNode *s = p->link[(int) !last];

          if (s != NULL) {
            if (!GT_RBTREE_NODE_IS_RED(s->link[(int) !last])
                  && !GT_RBTREE_NODE_IS_RED(s->link[last])) {
              /* Color flip */
              p->red = 0;
              s->red = 1;
              q->red = 1;
            } else {
              int dir2;
              gt_assert(g != NULL);
              dir2 = (int) (g->link[1] == p);

              if (GT_RBTREE_NODE_IS_RED(s->link[last]))
                g->link[dir2] = gt_rbtree_double(p, last);
              else if (GT_RBTREE_NODE_IS_RED(s->link[(int) !last]))
                g->link[dir2] = gt_rbtree_single(p, last);

              /* Ensure correct coloring */
              q->red = g->link[dir2]->red = 1;
              g->link[dir2]->link[0]->red = 0;
              g->link[dir2]->link[1]->red = 0;
            }
          }
        }
      }
    }

    /* Replace and remove the saved node */
    if (f != NULL) {
      if (tree->free != NULL)
        tree->free(f->key);
      f->key = q->key;
      gt_assert(p);
      p->link[(int) (p->link[1] == q)] = q->link[(int) (q->link[0] == NULL)];
      gt_free(q);
      rv = 0;
      --tree->size;
    }

    /* Update the root (it may be different) */
    tree->root = head.link[1];

    /* Make the root black for simplified logic */
    if (tree->root != NULL)
      tree->root->red = 0;
  }

  return rv;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movl $0xffffffff, 0x64(%rsp) # imm = 0xFFFFFFFF
cmpq $0x0, 0x70(%rsp)
jne 0x1b8a46
movq 0x48358b(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x35d5f4(%rip), %rsi    # 0x516013
leaq 0x4027d2(%rip), %rdx    # 0x5bb1f8
leaq 0x3a83ac(%rip), %rcx    # 0x560dd9
leaq 0x3a82fc(%rip), %r8     # 0x560d30
movl $0x149, %r9d            # imm = 0x149
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1b8a48
jmp 0x1b8a4a
cmpq $0x0, 0x68(%rsp)
jne 0x1b8a8a
movq 0x483547(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x35d5b0(%rip), %rsi    # 0x516013
leaq 0x38b874(%rip), %rdx    # 0x5442de
leaq 0x3a8368(%rip), %rcx    # 0x560dd9
leaq 0x3a82b8(%rip), %r8     # 0x560d30
movl $0x14a, %r9d            # imm = 0x14A
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1b8a8c
movq 0x70(%rsp), %rax
cmpq $0x0, (%rax)
je 0x1b8fc1
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x19360
movq $0x0, 0x20(%rsp)
movl $0x1, 0x1c(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x38(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x70(%rsp), %rax
movq (%rax), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x38(%rsp), %rax
movslq 0x1c(%rsp), %rcx
cmpq $0x0, 0x10(%rax,%rcx,8)
je 0x1b8ea6
movl 0x1c(%rsp), %eax
movl %eax, 0x18(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x38(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq %rax, 0x38(%rsp)
movq 0x70(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x38(%rsp), %rcx
movq 0x8(%rcx), %rdi
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rcx
movq 0x20(%rcx), %rdx
callq *%rax
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x1c(%rsp)
movq 0x70(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x38(%rsp), %rcx
movq 0x8(%rcx), %rdi
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rcx
movq 0x20(%rcx), %rdx
callq *%rax
cmpl $0x0, %eax
jne 0x1b8b89
movq 0x38(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x1b8b9f
movq 0x38(%rsp), %rax
cmpl $0x1, (%rax)
je 0x1b8ea1
movq 0x38(%rsp), %rax
movslq 0x1c(%rsp), %rcx
cmpq $0x0, 0x10(%rax,%rcx,8)
je 0x1b8bc9
movq 0x38(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
cmpl $0x1, (%rax)
je 0x1b8ea1
movq 0x38(%rsp), %rax
cmpl $0x0, 0x1c(%rsp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
cmpq $0x0, 0x10(%rax,%rcx,8)
je 0x1b8c34
movq 0x38(%rsp), %rax
cmpl $0x0, 0x1c(%rsp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq 0x10(%rax,%rcx,8), %rax
cmpl $0x1, (%rax)
jne 0x1b8c34
movq 0x38(%rsp), %rdi
movl 0x1c(%rsp), %esi
callq 0x1b8fd0
movq 0x30(%rsp), %rcx
movslq 0x18(%rsp), %rdx
movq %rax, 0x10(%rcx,%rdx,8)
movq %rax, 0x30(%rsp)
jmp 0x1b8e9f
movq 0x38(%rsp), %rax
cmpl $0x0, 0x1c(%rsp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
cmpq $0x0, 0x10(%rax,%rcx,8)
je 0x1b8c7c
movq 0x38(%rsp), %rax
cmpl $0x0, 0x1c(%rsp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq 0x10(%rax,%rcx,8), %rax
cmpl $0x1, (%rax)
je 0x1b8e9d
movq 0x30(%rsp), %rax
cmpl $0x0, 0x18(%rsp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq 0x10(%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0x1b8e9b
movq 0x10(%rsp), %rax
cmpl $0x0, 0x18(%rsp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
cmpq $0x0, 0x10(%rax,%rcx,8)
je 0x1b8cef
movq 0x10(%rsp), %rax
cmpl $0x0, 0x18(%rsp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq 0x10(%rax,%rcx,8), %rax
cmpl $0x1, (%rax)
je 0x1b8d3b
movq 0x10(%rsp), %rax
movslq 0x18(%rsp), %rcx
cmpq $0x0, 0x10(%rax,%rcx,8)
je 0x1b8d15
movq 0x10(%rsp), %rax
movslq 0x18(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
cmpl $0x1, (%rax)
je 0x1b8d3b
movq 0x30(%rsp), %rax
movl $0x0, (%rax)
movq 0x10(%rsp), %rax
movl $0x1, (%rax)
movq 0x38(%rsp), %rax
movl $0x1, (%rax)
jmp 0x1b8e99
jmp 0x1b8d3d
cmpq $0x0, 0x28(%rsp)
jne 0x1b8d7d
movq 0x483254(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x35d2bd(%rip), %rsi    # 0x516013
leaq 0x3cd8a0(%rip), %rdx    # 0x5865fd
leaq 0x3a8075(%rip), %rcx    # 0x560dd9
leaq 0x3a7fc5(%rip), %r8     # 0x560d30
movl $0x175, %r9d            # imm = 0x175
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1b8d7f
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rax
cmpq 0x30(%rsp), %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0xc(%rsp)
movq 0x10(%rsp), %rax
movslq 0x18(%rsp), %rcx
cmpq $0x0, 0x10(%rax,%rcx,8)
je 0x1b8de1
movq 0x10(%rsp), %rax
movslq 0x18(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
cmpl $0x1, (%rax)
jne 0x1b8de1
movq 0x30(%rsp), %rdi
movl 0x18(%rsp), %esi
callq 0x1b9060
movq %rax, %rdx
movq 0x28(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq %rdx, 0x10(%rax,%rcx,8)
jmp 0x1b8e47
movq 0x10(%rsp), %rax
cmpl $0x0, 0x18(%rsp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
cmpq $0x0, 0x10(%rax,%rcx,8)
je 0x1b8e45
movq 0x10(%rsp), %rax
cmpl $0x0, 0x18(%rsp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq 0x10(%rax,%rcx,8), %rax
cmpl $0x1, (%rax)
jne 0x1b8e45
movq 0x30(%rsp), %rdi
movl 0x18(%rsp), %esi
callq 0x1b8fd0
movq %rax, %rdx
movq 0x28(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq %rdx, 0x10(%rax,%rcx,8)
jmp 0x1b8e47
movq 0x28(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movl $0x1, (%rax)
movq 0x38(%rsp), %rax
movl $0x1, (%rax)
movq 0x28(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq 0x10(%rax), %rax
movl $0x0, (%rax)
movq 0x28(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
movl $0x0, (%rax)
jmp 0x1b8e9b
jmp 0x1b8e9d
jmp 0x1b8e9f
jmp 0x1b8ea1
jmp 0x1b8ae1
cmpq $0x0, 0x20(%rsp)
je 0x1b8f99
movq 0x70(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1b8ed2
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rdi
callq *%rax
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, 0x30(%rsp)
jne 0x1b8f24
movq 0x4830ad(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x35d116(%rip), %rsi    # 0x516013
leaq 0x3af23e(%rip), %rdx    # 0x568142
leaq 0x3a7ece(%rip), %rcx    # 0x560dd9
leaq 0x3a7e1e(%rip), %r8     # 0x560d30
movl $0x18c, %r9d            # imm = 0x18C
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1b8f26
movq 0x38(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq $0x0, 0x10(%rcx)
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq 0x10(%rax,%rcx,8), %rdx
movq 0x30(%rsp), %rax
movq 0x30(%rsp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x38(%rsp), %rcx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq %rdx, 0x10(%rax,%rcx,8)
movq 0x38(%rsp), %rdi
leaq 0x3a7dba(%rip), %rsi    # 0x560d30
movl $0x18e, %edx            # imm = 0x18E
callq 0xe88c0
movl $0x0, 0x64(%rsp)
movq 0x70(%rsp), %rax
movq 0x18(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x18(%rax)
movq 0x58(%rsp), %rcx
movq 0x70(%rsp), %rax
movq %rcx, (%rax)
movq 0x70(%rsp), %rax
cmpq $0x0, (%rax)
je 0x1b8fbf
movq 0x70(%rsp), %rax
movq (%rax), %rax
movl $0x0, (%rax)
jmp 0x1b8fc1
movl 0x64(%rsp), %eax
addq $0x78, %rsp
retq
nopw (%rax,%rax)