// File: /workspace/github_c_makefile_star2_O1/attractivechaos[P]rb-eval/rb.c
// Function: rb_delete
void *
rb_delete (struct rb_table *tree, const void *item)
{
  struct rb_node *pa[RB_MAX_HEIGHT]; /* Nodes on stack. */
  unsigned char da[RB_MAX_HEIGHT];   /* Directions moved from stack nodes. */
  int k;                             /* Stack height. */

  struct rb_node *p;    /* The node to delete, or a node part way to it. */
  int cmp;              /* Result of comparison between |item| and |p|. */

  assert (tree != NULL && item != NULL);

  k = 0;
  p = (struct rb_node *) &tree->rb_root;
  for (cmp = -1; cmp != 0;
       cmp = tree->rb_compare (item, p->rb_data, tree->rb_param))
    {
      int dir = cmp > 0;

      pa[k] = p;
      da[k++] = dir;

      p = p->rb_link[dir];
      if (p == NULL)
        return NULL;
    }
  item = p->rb_data;

  if (p->rb_link[1] == NULL)
    pa[k - 1]->rb_link[da[k - 1]] = p->rb_link[0];
  else
    {
      enum rb_color t;
      struct rb_node *r = p->rb_link[1];

      if (r->rb_link[0] == NULL)
        {
          r->rb_link[0] = p->rb_link[0];
          t = r->rb_color;
          r->rb_color = p->rb_color;
          p->rb_color = t;
          pa[k - 1]->rb_link[da[k - 1]] = r;
          da[k] = 1;
          pa[k++] = r;
        }
      else
        {
          struct rb_node *s;
          int j = k++;

          for (;;)
            {
              da[k] = 0;
              pa[k++] = r;
              s = r->rb_link[0];
              if (s->rb_link[0] == NULL)
                break;

              r = s;
            }

          da[j] = 1;
          pa[j] = s;
          pa[j - 1]->rb_link[da[j - 1]] = s;

          s->rb_link[0] = p->rb_link[0];
          r->rb_link[0] = s->rb_link[1];
          s->rb_link[1] = p->rb_link[1];

          t = s->rb_color;
          s->rb_color = p->rb_color;
          p->rb_color = t;
        }
    }

  if (p->rb_color == RB_BLACK)
    {
      for (;;)
        {
          struct rb_node *x = pa[k - 1]->rb_link[da[k - 1]];
          if (x != NULL && x->rb_color == RB_RED)
            {
              x->rb_color = RB_BLACK;
              break;
            }
          if (k < 2)
            break;

          if (da[k - 1] == 0)
            {
              struct rb_node *w = pa[k - 1]->rb_link[1];

              if (w->rb_color == RB_RED)
                {
                  w->rb_color = RB_BLACK;
                  pa[k - 1]->rb_color = RB_RED;

                  pa[k - 1]->rb_link[1] = w->rb_link[0];
                  w->rb_link[0] = pa[k - 1];
                  pa[k - 2]->rb_link[da[k - 2]] = w;

                  pa[k] = pa[k - 1];
                  da[k] = 0;
                  pa[k - 1] = w;
                  k++;

                  w = pa[k - 1]->rb_link[1];
                }

              if ((w->rb_link[0] == NULL
                   || w->rb_link[0]->rb_color == RB_BLACK)
                  && (w->rb_link[1] == NULL
                      || w->rb_link[1]->rb_color == RB_BLACK))
                w->rb_color = RB_RED;
              else
                {
                  if (w->rb_link[1] == NULL
                      || w->rb_link[1]->rb_color == RB_BLACK)
                    {
                      struct rb_node *y = w->rb_link[0];
                      y->rb_color = RB_BLACK;
                      w->rb_color = RB_RED;
                      w->rb_link[0] = y->rb_link[1];
                      y->rb_link[1] = w;
                      w = pa[k - 1]->rb_link[1] = y;
                    }

                  w->rb_color = pa[k - 1]->rb_color;
                  pa[k - 1]->rb_color = RB_BLACK;
                  w->rb_link[1]->rb_color = RB_BLACK;

                  pa[k - 1]->rb_link[1] = w->rb_link[0];
                  w->rb_link[0] = pa[k - 1];
                  pa[k - 2]->rb_link[da[k - 2]] = w;
                  break;
                }
            }
          else
            {
              struct rb_node *w = pa[k - 1]->rb_link[0];

              if (w->rb_color == RB_RED)
                {
                  w->rb_color = RB_BLACK;
                  pa[k - 1]->rb_color = RB_RED;

                  pa[k - 1]->rb_link[0] = w->rb_link[1];
                  w->rb_link[1] = pa[k - 1];
                  pa[k - 2]->rb_link[da[k - 2]] = w;

                  pa[k] = pa[k - 1];
                  da[k] = 1;
                  pa[k - 1] = w;
                  k++;

                  w = pa[k - 1]->rb_link[0];
                }

              if ((w->rb_link[0] == NULL
                   || w->rb_link[0]->rb_color == RB_BLACK)
                  && (w->rb_link[1] == NULL
                      || w->rb_link[1]->rb_color == RB_BLACK))
                w->rb_color = RB_RED;
              else
                {
                  if (w->rb_link[0] == NULL
                      || w->rb_link[0]->rb_color == RB_BLACK)
                    {
                      struct rb_node *y = w->rb_link[1];
                      y->rb_color = RB_BLACK;
                      w->rb_color = RB_RED;
                      w->rb_link[1] = y->rb_link[0];
                      y->rb_link[0] = w;
                      w = pa[k - 1]->rb_link[0] = y;
                    }

                  w->rb_color = pa[k - 1]->rb_color;
                  pa[k - 1]->rb_color = RB_BLACK;
                  w->rb_link[0]->rb_color = RB_BLACK;

                  pa[k - 1]->rb_link[0] = w->rb_link[1];
                  w->rb_link[1] = pa[k - 1];
                  pa[k - 2]->rb_link[da[k - 2]] = w;
                  break;
                }
            }

          k--;
        }

    }

  tree->rb_alloc->libavl_free (tree->rb_alloc, p);
  tree->rb_count--;
  tree->rb_generation++;
  return (void *) item;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b0, %rsp            # imm = 0x1B0
testq %rdi, %rdi
je 0x1877
movq %rsi, %r12
testq %rsi, %rsi
je 0x1877
movq %rdi, %rbx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %r14d, %r14d
xorl %r13d, %r13d
movq %rdi, %r15
xorl %ecx, %ecx
testl %eax, %eax
setg (%rsp,%r13)
setg %cl
movq %r15, 0x30(%rsp,%r13,8)
movq (%r15,%rcx,8), %r15
testq %r15, %r15
je 0x1629
incq %r13
movq 0x10(%r15), %rsi
movq 0x10(%rbx), %rdx
movq %r12, %rdi
callq *0x8(%rbx)
testl %eax, %eax
jne 0x151f
movq 0x8(%r15), %rax
movq 0x10(%r15), %r14
leaq -0x1(%r13), %rcx
testq %rax, %rax
je 0x15c9
cmpq $0x0, (%rax)
je 0x15dd
leaq 0x1(%r13), %rdx
movq %rax, %rsi
movb $0x0, (%rsp,%rdx)
movq %rax, 0x30(%rsp,%rdx,8)
incq %rdx
movq (%rax), %rax
cmpq $0x0, (%rax)
jne 0x156d
movl %r13d, %edi
movb $0x1, (%rsp,%rdi)
movq %rax, 0x30(%rsp,%rdi,8)
movl %ecx, %ecx
movq 0x30(%rsp,%rcx,8), %rdi
movzbl (%rsp,%rcx), %ecx
movq %rax, (%rdi,%rcx,8)
movq (%r15), %rcx
movq %rcx, (%rax)
movq 0x8(%rax), %rcx
movq %rcx, (%rsi)
movq 0x8(%r15), %rcx
movq %rcx, 0x8(%rax)
movb 0x18(%rax), %cl
movb 0x18(%r15), %sil
movb %sil, 0x18(%rax)
movb %cl, 0x18(%r15)
movl %edx, %r13d
jmp 0x1610
movq (%r15), %rax
movl %ecx, %ecx
movq 0x30(%rsp,%rcx,8), %rdx
movzbl (%rsp,%rcx), %ecx
movq %rax, (%rdx,%rcx,8)
jmp 0x1610
movq (%r15), %rdx
movq %rdx, (%rax)
movb 0x18(%rax), %dl
movb 0x18(%r15), %sil
movb %sil, 0x18(%rax)
movb %dl, 0x18(%r15)
movl %ecx, %ecx
movq 0x30(%rsp,%rcx,8), %rdx
movzbl (%rsp,%rcx), %ecx
movq %rax, (%rdx,%rcx,8)
movl %r13d, %ecx
movb $0x1, (%rsp,%rcx)
incl %r13d
movq %rax, 0x30(%rsp,%rcx,8)
cmpb $0x0, 0x18(%r15)
je 0x163d
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq *0x8(%rdi)
decq 0x20(%rbx)
incq 0x28(%rbx)
movq %r14, %rax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
xorl %eax, %eax
movb $0x1, %cl
movslq %r13d, %rdi
movq 0x28(%rsp,%rdi,8), %rsi
movzbl -0x1(%rsp,%rdi), %r8d
movq (%rsi,%r8,8), %rdx
testq %rdx, %rdx
je 0x166c
cmpb $0x1, 0x18(%rdx)
jne 0x166c
movb $0x0, 0x18(%rdx)
movl $0x7, %edx
jmp 0x17f2
movl $0x7, %edx
cmpl $0x2, %r13d
jl 0x17f2
testb %r8b, %r8b
je 0x1761
movq (%rsi), %rdx
cmpb $0x1, 0x18(%rdx)
jne 0x16c8
movb $0x0, 0x18(%rdx)
movb %cl, 0x18(%rsi)
movq 0x8(%rdx), %r8
movq %r8, (%rsi)
movq %rsi, 0x8(%rdx)
leal -0x2(%r13), %r8d
movq 0x30(%rsp,%r8,8), %r9
movzbl (%rsp,%r8), %r8d
movq %rdx, (%r9,%r8,8)
movl %r13d, %r8d
movq %rsi, 0x30(%rsp,%r8,8)
movb %cl, (%rsp,%r8)
movq %rdx, 0x28(%rsp,%rdi,8)
incl %r13d
movq (%rsi), %rdx
movq (%rdx), %rsi
testq %rsi, %rsi
je 0x16d6
cmpb $0x0, 0x18(%rsi)
jne 0x16ed
movq 0x8(%rdx), %rdi
testq %rdi, %rdi
je 0x17df
cmpb $0x0, 0x18(%rdi)
je 0x17df
testq %rsi, %rsi
je 0x16f8
cmpb $0x0, 0x18(%rsi)
jne 0x171d
movq 0x8(%rdx), %rsi
movb $0x0, 0x18(%rsi)
movb $0x1, 0x18(%rdx)
movq (%rsi), %rdi
movq %rdi, 0x8(%rdx)
movq %rdx, (%rsi)
leal -0x1(%r13), %edx
movq 0x30(%rsp,%rdx,8), %rdx
movq %rsi, (%rdx)
movq %rsi, %rdx
leal -0x1(%r13), %esi
movq 0x30(%rsp,%rsi,8), %rdi
movb 0x18(%rdi), %sil
movb %sil, 0x18(%rdx)
xorl %esi, %esi
movb %sil, 0x18(%rdi)
movq (%rdx), %r8
movb %sil, 0x18(%r8)
movq 0x8(%rdx), %r8
movq %r8, (%rdi)
movq %rdi, 0x8(%rdx)
leal -0x2(%r13), %edi
movq 0x30(%rsp,%rdi,8), %r8
movzbl (%rsp,%rdi), %edi
movq %rdx, (%r8,%rdi,8)
movl $0x7, %edx
jmp 0x17e8
movq 0x8(%rsi), %rdx
cmpb $0x1, 0x18(%rdx)
jne 0x17a6
movb %al, 0x18(%rdx)
movb $0x1, 0x18(%rsi)
movq (%rdx), %r8
movq %r8, 0x8(%rsi)
movq %rsi, (%rdx)
leal -0x2(%r13), %r8d
movq 0x30(%rsp,%r8,8), %r9
movzbl (%rsp,%r8), %r8d
movq %rdx, (%r9,%r8,8)
movl %r13d, %r8d
movq %rsi, 0x30(%rsp,%r8,8)
movb %al, (%rsp,%r8)
movq %rdx, 0x28(%rsp,%rdi,8)
incl %r13d
movq 0x8(%rsi), %rdx
movq (%rdx), %rsi
testq %rsi, %rsi
je 0x17b4
cmpb $0x0, 0x18(%rsi)
jne 0x17cb
movq 0x8(%rdx), %rdi
testq %rdi, %rdi
je 0x1860
cmpb $0x0, 0x18(%rdi)
je 0x1860
movq 0x8(%rdx), %rdi
testq %rdi, %rdi
je 0x17ff
cmpb $0x0, 0x18(%rdi)
je 0x17ff
movq %rdx, %rsi
jmp 0x181f
movb $0x1, 0x18(%rdx)
xorl %edx, %edx
movb $0x1, %sil
testb %sil, %sil
je 0x17f2
decl %r13d
xorl %edx, %edx
testl %edx, %edx
je 0x1641
jmp 0x1617
movb $0x0, 0x18(%rsi)
movb $0x1, 0x18(%rdx)
movq 0x8(%rsi), %rdi
movq %rdi, (%rdx)
movq %rdx, 0x8(%rsi)
leal -0x1(%r13), %edx
movq 0x30(%rsp,%rdx,8), %rdx
movq %rsi, 0x8(%rdx)
leal -0x1(%r13), %edx
movq 0x30(%rsp,%rdx,8), %rdx
movb 0x18(%rdx), %dil
movb %dil, 0x18(%rsi)
xorl %edi, %edi
movb %dil, 0x18(%rdx)
movq 0x8(%rsi), %r8
movb %dil, 0x18(%r8)
movq (%rsi), %r8
movq %r8, 0x8(%rdx)
movq %rdx, (%rsi)
leal -0x2(%r13), %edx
movq 0x30(%rsp,%rdx,8), %r8
movzbl (%rsp,%rdx), %edx
movq %rsi, (%r8,%rdx,8)
movl $0x7, %edx
jmp 0x1869
movb $0x1, 0x18(%rdx)
xorl %edx, %edx
movb $0x1, %dil
testb %dil, %dil
jne 0x17ed
jmp 0x17f2
leaq 0x1942(%rip), %rdi      # 0x31c0
leaq 0x178f(%rip), %rsi      # 0x3014
leaq 0x1841(%rip), %rcx      # 0x30cd
movl $0xf2, %edx
callq 0x1040