FsRtlSplitLocks

void __fastcall FsRtlSplitLocks(__int64 a1, _RTL_SPLAY_LINKS *a2, unsigned __int64 *a3, _RTL_SPLAY_LINKS **a4){
  __int64 v5; 
  _RTL_SPLAY_LINKS *v6; 
  int v7; 
  unsigned __int64 v8; 
  _RTL_SPLAY_LINKS *Parent; 
  unsigned __int64 v10; 
  _RTL_SPLAY_LINKS *LeftChild; 
  _RTL_SPLAY_LINKS *v12; 
  _RTL_SPLAY_LINKS *v13; 
  _RTL_SPLAY_LINKS *v14; 
  _RTL_SPLAY_LINKS *v15; 
  _RTL_SPLAY_LINKS *v16; 
  _RTL_SPLAY_LINKS *v17; 
  _RTL_SPLAY_LINKS *v18; 
  _RTL_SPLAY_LINKS *v19; 
  unsigned __int64 v20; 

  v5 = a1;
  v6 = 0i64;
  v7 = 0;
  if( *(_BYTE *)(a1 + 8) )
  {
    v8 = *(_QWORD *)(a1 + 16);
    a2 = (_RTL_SPLAY_LINKS *)a1;
    *(_BYTE *)(a1 + 8) = 0;
  }
  else
  {
    v8 = *a3;
    v6 = *a4;
    if( *a3 <= (unsigned __int64)*a4 || !*(_QWORD *)a1 )
      return;
  }
  Parent = a2->Parent;
  v10 = *(_QWORD *)(a1 + 16);
  v20 = v10;
  if( a2->Parent )
  {
    LeftChild = 0i64;
    v12 = a2->Parent;
    do
    {
      if( *(_RTL_SPLAY_LINKS **)v5 == v12 )
      {
        v6 = Parent[2].Parent;
        LeftChild = Parent->LeftChild;
        if( v10 <= v8 )
          *(_QWORD *)(v5 + 16) = v6;
        goto LABEL_10;
      }
      v13 = Parent->LeftChild;
      if( v13 > v6 && (Parent->RightChild || v13 != LeftChild) )
      {
        v15 = (_RTL_SPLAY_LINKS *)ExAllocateFromNPagedLookasideList((_NPAGED_LOOKASIDE_LIST *)((char *)&WheapErrorSourceTable
                                                                                             + 2472));
        v16 = v15;
        if( v15 )
        {
          v17 = v15 + 1;
          LOBYTE(v15->LeftChild) = 0;
          v15[1].Parent = v15 + 1;
          v18 = (_RTL_SPLAY_LINKS *)(v5 + 24);
          v17->LeftChild = 0i64;
          v17->RightChild = 0i64;
          if( *(_QWORD *)(v5 + 40) )
          {
            v18 = RtlRealSuccessor((_RTL_SPLAY_LINKS *)(v5 + 24));
            v18->LeftChild = v17;
          }
          else
          {
            *(_QWORD *)(v5 + 40) = v17;
          }
          v17->Parent = v18;
          Parent = v16;
          v16->Parent = a2->Parent;
          a2->Parent = 0i64;
          v16[2].Parent = *(_RTL_SPLAY_LINKS **)(v5 + 48);
          v19 = *(_RTL_SPLAY_LINKS **)(v5 + 16);
          *(_QWORD *)(v5 + 48) = a2;
          v16->RightChild = v19;
          *(_QWORD *)(v5 + 16) = v6;
          if( v7 )
            v7 = 0;
          else
            *(_BYTE *)(v5 + 8) = 0;
          v10 = v20;
          v5 = (__int64)v16;
          goto LABEL_10;
        }
        v10 = v20;
        if( *(_BYTE *)(v5 + 8) )
          v7 = 1;
        *(_BYTE *)(v5 + 8) = 1;
      }
      if( v10 > v8 && Parent->LeftChild > (_RTL_SPLAY_LINKS *)v8 )
        return;
      v14 = Parent[2].Parent;
      if( v6 < v14 )
      {
        v6 = Parent[2].Parent;
        if( v10 <= v8 )
          *(_QWORD *)(v5 + 16) = v14;
      }
LABEL_10:
      a2 = Parent;
      Parent = Parent->Parent;
      v12 = Parent;
    }
    while( Parent );
  }
  *(_QWORD *)(v5 + 16) = v6;
}

Referenced by:

FsRtlFastUnlockSingleShared
FsRtlPrivateFastUnlockAll
FsRtlPrivateInsertSharedLock