SwapSplayLinks

VOID __stdcall SwapSplayLinks(_RTL_SPLAY_LINKS *Link1, _RTL_SPLAY_LINKS *Link2){
  _RTL_SPLAY_LINKS *v2; 
  _RTL_SPLAY_LINKS *Parent; 
  _RTL_SPLAY_LINKS *v4; 
  _RTL_SPLAY_LINKS *v5; 
  _RTL_SPLAY_LINKS *v6; 
  __int64 v7; 
  _RTL_SPLAY_LINKS *v8; 
  _RTL_SPLAY_LINKS *v9; 
  _RTL_SPLAY_LINKS *v10; 
  _RTL_SPLAY_LINKS *v11; 
  _RTL_SPLAY_LINKS *v12; 
  _RTL_SPLAY_LINKS *v13; 
  _RTL_SPLAY_LINKS *v14; 
  _RTL_SPLAY_LINKS *v15; 
  _RTL_SPLAY_LINKS *LeftChild; 
  _RTL_SPLAY_LINKS *RightChild; 
  _RTL_SPLAY_LINKS *v18; 
  _RTL_SPLAY_LINKS *v19; 
  __int64 v20; 
  _RTL_SPLAY_LINKS *v21; 
  _RTL_SPLAY_LINKS *v22; 
  _RTL_SPLAY_LINKS *v23; 
  __int64 v24; 
  _RTL_SPLAY_LINKS *v25; 

  v2 = Link1;
  Parent = Link1->Parent;
  if( Parent == v2 || (v4 = Link2->Parent, v5 = Parent, Link2->Parent == v2) )
  {
    v5 = Link2->Parent;
    v25 = v2;
    v2 = Link2;
    v4 = Parent;
    Link2 = v25;
  }
  if( v5 == Link2 )
  {
    if( v4 == Link2 )
    {
      v15 = v2;
    }
    else
    {
      v24 = 8i64;
      if( v4->LeftChild != Link2 )
        v24 = 16i64;
      *(_RTL_SPLAY_LINKS **)((char *)&v4->Parent + v24) = v2;
      v15 = Link2->Parent;
    }
    v2->Parent = v15;
    LeftChild = v2->LeftChild;
    v2->LeftChild = Link2->LeftChild;
    RightChild = Link2->RightChild;
    Link2->LeftChild = LeftChild;
    v18 = v2->RightChild;
    v2->RightChild = RightChild;
    Link2->RightChild = v18;
    v11 = v2->LeftChild;
    if( v11 == v2 )
    {
      v2->LeftChild = Link2;
      v11 = Link2;
    }
    else
    {
      v2->RightChild = Link2;
    }
  }
  else
  {
    v6 = v5->LeftChild;
    v7 = 8i64;
    if( v4 == Link2 )
    {
      if( v6 != v2 )
        v7 = 16i64;
      *(_RTL_SPLAY_LINKS **)((char *)&v5->Parent + v7) = Link2;
      Link2->Parent = v2->Parent;
      v2->Parent = v2;
    }
    else
    {
      v19 = v4->LeftChild;
      v20 = 8i64;
      v21 = v19;
      if( v6 != v2 )
        v20 = 16i64;
      if( v19 != Link2 )
        v21 = v4->RightChild;
      v22 = *(_RTL_SPLAY_LINKS **)((char *)&v5->Parent + v20);
      if( v19 != Link2 )
        v7 = 16i64;
      *(_RTL_SPLAY_LINKS **)((char *)&v5->Parent + v20) = v21;
      *(_RTL_SPLAY_LINKS **)((char *)&v4->Parent + v7) = v22;
      v23 = v2->Parent;
      v2->Parent = Link2->Parent;
      Link2->Parent = v23;
    }
    v8 = v2->LeftChild;
    v2->LeftChild = Link2->LeftChild;
    v9 = Link2->RightChild;
    Link2->LeftChild = v8;
    v10 = v2->RightChild;
    v2->RightChild = v9;
    Link2->RightChild = v10;
    v11 = v2->LeftChild;
  }
  if( v11 )
    v11->Parent = v2;
  v12 = v2->RightChild;
  if( v12 )
    v12->Parent = v2;
  v13 = Link2->LeftChild;
  if( v13 )
    v13->Parent = Link2;
  v14 = Link2->RightChild;
  if( v14 )
    v14->Parent = Link2;
}

Referenced by:

RtlDelete
RtlDeleteNoSplay