// File: /workspace/github_c_makefile_star2_O3/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 0x1838
movq %rsi, %r12
testq %rsi, %rsi
je 0x1838
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 0x162e
incq %r13
movq 0x10(%r15), %rsi
movq 0x10(%rbx), %rdx
movq %r12, %rdi
callq *0x8(%rbx)
testl %eax, %eax
jne 0x1514
movq 0x8(%r15), %rax
movq 0x10(%r15), %r14
leaq -0x1(%r13), %rcx
testq %rax, %rax
je 0x15c2
movq (%rax), %rdi
testq %rdi, %rdi
je 0x15da
leaq 0x1(%r13), %rdx
movq %rax, %rsi
movq %rdi, %rax
movb $0x0, (%rsp,%rdx)
movq %rsi, 0x30(%rsp,%rdx,8)
incq %rdx
movq (%rdi), %rdi
testq %rdi, %rdi
jne 0x1564
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), %sil
movb 0x18(%r15), %cl
movb %cl, 0x18(%rax)
movb %sil, 0x18(%r15)
movl %edx, %r13d
jmp 0x160d
movq (%r15), %rax
movl %ecx, %ecx
movq 0x30(%rsp,%rcx,8), %rdx
movzbl (%rsp,%rcx), %ecx
movq %rax, (%rdx,%rcx,8)
movb 0x18(%r15), %sil
jmp 0x160d
movq (%r15), %rdx
movq %rdx, (%rax)
movb 0x18(%rax), %sil
movb 0x18(%r15), %dl
movb %dl, 0x18(%rax)
movb %sil, 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)
testb %sil, %sil
je 0x1642
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq *0x8(%rdi)
movdqu 0x20(%rbx), %xmm0
paddq 0x19e7(%rip), %xmm0     # 0x3010
movdqu %xmm0, 0x20(%rbx)
movq %r14, %rax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
xorl %ecx, %ecx
movb $0x1, %dl
movslq %r13d, %rdi
movq 0x28(%rsp,%rdi,8), %rsi
movzbl -0x1(%rsp,%rdi), %eax
movq (%rsi,%rax,8), %r8
testq %r8, %r8
je 0x1667
cmpb $0x1, 0x18(%r8)
je 0x1746
cmpl $0x2, %r13d
jl 0x1612
testb %al, %al
je 0x16d8
movq (%rsi), %rax
cmpb $0x1, 0x18(%rax)
jne 0x16b5
movb $0x0, 0x18(%rax)
movb %dl, 0x18(%rsi)
movq 0x8(%rax), %r8
movq %r8, (%rsi)
movq %rsi, 0x8(%rax)
leal -0x2(%r13), %r8d
movq 0x30(%rsp,%r8,8), %r9
movzbl (%rsp,%r8), %r8d
movq %rax, (%r9,%r8,8)
movl %r13d, %r8d
movq %rsi, 0x30(%rsp,%r8,8)
movb %dl, (%rsp,%r8)
movq %rax, 0x28(%rsp,%rdi,8)
incl %r13d
movq (%rsi), %rax
movq (%rax), %rsi
testq %rsi, %rsi
je 0x16c7
cmpb $0x0, 0x18(%rsi)
jne 0x175f
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x173a
cmpb $0x0, 0x18(%rdi)
je 0x173a
jmp 0x1750
movq 0x8(%rsi), %rax
cmpb $0x1, 0x18(%rax)
jne 0x171d
movb %cl, 0x18(%rax)
movb $0x1, 0x18(%rsi)
movq (%rax), %r8
movq %r8, 0x8(%rsi)
movq %rsi, (%rax)
leal -0x2(%r13), %r8d
movq 0x30(%rsp,%r8,8), %r9
movzbl (%rsp,%r8), %r8d
movq %rax, (%r9,%r8,8)
movl %r13d, %r8d
movq %rsi, 0x30(%rsp,%r8,8)
movb %cl, (%rsp,%r8)
movq %rax, 0x28(%rsp,%rdi,8)
incl %r13d
movq 0x8(%rsi), %rax
movq (%rax), %rsi
testq %rsi, %rsi
je 0x172b
cmpb $0x0, 0x18(%rsi)
jne 0x1768
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x173a
cmpb $0x0, 0x18(%rdi)
jne 0x1771
movb $0x1, 0x18(%rax)
decl %r13d
jmp 0x1646
movb $0x0, 0x18(%r8)
jmp 0x1612
testq %rsi, %rsi
je 0x17df
cmpb $0x0, 0x18(%rsi)
je 0x17db
leal -0x1(%r13), %ecx
jmp 0x1803
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x1783
cmpb $0x0, 0x18(%rdi)
je 0x1783
leal -0x1(%r13), %ecx
movq %rsi, %rdx
movq %rax, %rsi
jmp 0x17aa
movb $0x0, 0x18(%rsi)
movb $0x1, 0x18(%rax)
movq 0x8(%rsi), %rcx
movq %rcx, (%rax)
movq %rax, 0x8(%rsi)
leal -0x1(%r13), %ecx
movq 0x30(%rsp,%rcx,8), %rax
movq %rsi, 0x8(%rax)
movq (%rsi), %rdx
movq 0x8(%rsi), %rdi
movq 0x30(%rsp,%rcx,8), %rax
movb 0x18(%rax), %cl
movb %cl, 0x18(%rsi)
xorl %ecx, %ecx
movb %cl, 0x18(%rax)
movb %cl, 0x18(%rdi)
movq %rdx, 0x8(%rax)
movq %rax, (%rsi)
addl $-0x2, %r13d
movq 0x30(%rsp,%r13,8), %rax
movzbl (%rsp,%r13), %ecx
movq %rsi, (%rax,%rcx,8)
jmp 0x1612
movq 0x8(%rax), %rdi
movb $0x0, 0x18(%rdi)
movb $0x1, 0x18(%rax)
movq (%rdi), %rcx
movq %rcx, 0x8(%rax)
movq %rax, (%rdi)
leal -0x1(%r13), %ecx
movq 0x30(%rsp,%rcx,8), %rax
movq %rdi, (%rax)
movq (%rdi), %rsi
movq %rdi, %rax
movq 0x30(%rsp,%rcx,8), %rcx
movb 0x18(%rcx), %dl
movb %dl, 0x18(%rax)
xorl %edx, %edx
movb %dl, 0x18(%rcx)
movb %dl, 0x18(%rsi)
movq 0x8(%rax), %rdx
movq %rdx, (%rcx)
movq %rcx, 0x8(%rax)
addl $-0x2, %r13d
movq 0x30(%rsp,%r13,8), %rcx
movzbl (%rsp,%r13), %edx
movq %rax, (%rcx,%rdx,8)
jmp 0x1612
leaq 0x199d(%rip), %rdi      # 0x31dc
leaq 0x17ea(%rip), %rsi      # 0x3030
leaq 0x189c(%rip), %rcx      # 0x30e9
movl $0xf2, %edx
callq 0x1040