struct rtavl_node *x = y->rtavl_link[1];
if (x->rtavl_balance == +1)
  {
    w = x;
    if (x->rtavl_link[0] == NULL)
      {
        y->rtavl_rtag = RTAVL_THREAD;
        y->rtavl_link[1] = x;
      }
    else
      y->rtavl_link[1] = x->rtavl_link[0];
    x->rtavl_link[0] = y;
    x->rtavl_balance = y->rtavl_balance = 0;
  }
else
  {
    assert (x->rtavl_balance == -1);
    w = x->rtavl_link[0];
    x->rtavl_link[0] = w->rtavl_link[1];
    w->rtavl_link[1] = x;
    y->rtavl_link[1] = w->rtavl_link[0];
    w->rtavl_link[0] = y;
    if (w->rtavl_balance == +1)
      x->rtavl_balance = 0, y->rtavl_balance = -1;
    else if (w->rtavl_balance == 0)
      x->rtavl_balance = y->rtavl_balance = 0;
    else /* |w->rtavl_balance == -1| */
      x->rtavl_balance = +1, y->rtavl_balance = 0;
    w->rtavl_balance = 0;
    if (y->rtavl_link[1] == NULL)
      {
        y->rtavl_rtag = RTAVL_THREAD;
        y->rtavl_link[1] = w;
      }
    if (w->rtavl_rtag == RTAVL_THREAD)
      {
        x->rtavl_link[0] = NULL;
        w->rtavl_rtag = RTAVL_CHILD;
      }
  }
