// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
testq %rdi, %rdi
je 0x1819
movq %rsi, %r12
testq %rsi, %rsi
je 0x1819
movq %rdi, %rbx
pushq $-0x1
popq %rax
movabsq $-0x100000000, %rbp     # imm = 0xFFFFFFFF00000000
movabsq $0x100000000, %r14      # imm = 0x100000000
xorl %r13d, %r13d
movq %rdi, %r15
testl %eax, %eax
je 0x150c
setg %al
setg (%rsp,%r13)
movq %r15, 0x30(%rsp,%r13,8)
movzbl %al, %eax
movq (%r15,%rax,8), %r15
testq %r15, %r15
je 0x1590
incq %r13
movq 0x10(%r15), %rsi
movq 0x10(%rbx), %rdx
movq %r12, %rdi
callq *0x8(%rbx)
addq %r14, %rbp
jmp 0x14d5
movq 0x8(%r15), %rax
movq 0x10(%r15), %r14
testq %rax, %rax
je 0x1595
movq (%rax), %rsi
testq %rsi, %rsi
je 0x15b6
leaq 0x1(%r13), %rcx
movq %rax, %rdx
movq %rsi, %rax
movb $0x0, (%rsp,%rcx)
movq %rdx, 0x30(%rsp,%rcx,8)
incq %rcx
movq (%rsi), %rsi
testq %rsi, %rsi
jne 0x1529
movl %r13d, %esi
movb $0x1, (%rsp,%rsi)
movq %rax, 0x30(%rsp,%rsi,8)
movq %rbp, %rsi
sarq $0x20, %rsi
sarq $0x1d, %rbp
movq 0x30(%rsp,%rbp), %rdi
movzbl (%rsp,%rsi), %esi
movq %rax, (%rdi,%rsi,8)
movq (%r15), %rsi
movq %rsi, (%rax)
movq 0x8(%rax), %rsi
movq %rsi, (%rdx)
movq 0x8(%r15), %rdx
movq %rdx, 0x8(%rax)
movb 0x18(%rax), %dl
movb 0x18(%r15), %sil
movb %sil, 0x18(%rax)
movb %dl, 0x18(%r15)
movl %ecx, %r13d
jmp 0x15f1
xorl %r14d, %r14d
jmp 0x1611
movq (%r15), %rax
movq %rbp, %rcx
sarq $0x20, %rcx
sarq $0x1d, %rbp
movq 0x30(%rsp,%rbp), %rdx
movzbl (%rsp,%rcx), %ecx
movq %rax, (%rdx,%rcx,8)
movb 0x18(%r15), %dl
jmp 0x15f1
movq (%r15), %rcx
movq %rcx, (%rax)
movb 0x18(%rax), %dl
movb 0x18(%r15), %cl
movb %cl, 0x18(%rax)
movb %dl, 0x18(%r15)
movq %rbp, %rcx
sarq $0x20, %rcx
sarq $0x1d, %rbp
movq 0x30(%rsp,%rbp), %rsi
movzbl (%rsp,%rcx), %ecx
movq %rax, (%rsi,%rcx,8)
movl %r13d, %ecx
movb $0x1, (%rsp,%rcx)
incl %r13d
movq %rax, 0x30(%rsp,%rcx,8)
testb %dl, %dl
je 0x1626
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq *0x8(%rdi)
movdqu 0x20(%rbx), %xmm0
paddq 0x1a04(%rip), %xmm0     # 0x3010
movdqu %xmm0, 0x20(%rbx)
movq %r14, %rax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
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 0x164b
cmpb $0x1, 0x18(%r8)
je 0x1727
cmpl $0x2, %r13d
jl 0x15f5
movl %r13d, %r8d
testb %al, %al
je 0x16bc
movq (%rsi), %rax
cmpb $0x1, 0x18(%rax)
jne 0x1699
movb $0x0, 0x18(%rax)
movb %dl, 0x18(%rsi)
movq 0x8(%rax), %r9
movq %r9, (%rsi)
movq %rsi, 0x8(%rax)
leal -0x2(%r13), %r9d
movq 0x30(%rsp,%r9,8), %r10
movzbl (%rsp,%r9), %r9d
movq %rax, (%r10,%r9,8)
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 0x16ab
cmpb $0x0, 0x18(%rsi)
jne 0x1740
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x171b
cmpb $0x0, 0x18(%rdi)
je 0x171b
jmp 0x1731
movq 0x8(%rsi), %rax
cmpb $0x1, 0x18(%rax)
jne 0x16fe
movb %cl, 0x18(%rax)
movb $0x1, 0x18(%rsi)
movq (%rax), %r9
movq %r9, 0x8(%rsi)
movq %rsi, (%rax)
leal -0x2(%r13), %r9d
movq 0x30(%rsp,%r9,8), %r10
movzbl (%rsp,%r9), %r9d
movq %rax, (%r10,%r9,8)
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 0x170c
cmpb $0x0, 0x18(%rsi)
jne 0x1749
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x171b
cmpb $0x0, 0x18(%rdi)
jne 0x1752
movb $0x1, 0x18(%rax)
decl %r13d
jmp 0x162a
movb $0x0, 0x18(%r8)
jmp 0x15f5
testq %rsi, %rsi
je 0x17c0
cmpb $0x0, 0x18(%rsi)
je 0x17bc
leal -0x1(%r13), %ecx
jmp 0x17e4
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x1764
cmpb $0x0, 0x18(%rdi)
je 0x1764
leal -0x1(%r13), %ecx
movq %rsi, %rdx
movq %rax, %rsi
jmp 0x178b
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 0x15f5
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 0x15f5
leaq 0x19bc(%rip), %rdi      # 0x31dc
leaq 0x1809(%rip), %rsi      # 0x3030
leaq 0x18bb(%rip), %rcx      # 0x30e9
movl $0xf2, %edx
callq 0x1040