MiFreePartitionTree

VOID __fastcall MiFreePartitionTree(_MI_PARTITION *TargetPartition, _RTL_AVL_TREE *PageRoot, UINT64 Flags){
  int v3; 
  _RTL_BALANCED_NODE *Root; 
  BOOL v5; 
  int v6; 
  CHAR v7; 
  _RTL_BALANCED_NODE *v10; 
  _RTL_BALANCED_NODE *v11; 

  Root = PageRoot->Root;
  v5 = 0;
  v6 = v3;
  v7 = Flags;
  while( 1 )
  {
    if( !Root )
      return;
    RtlAvlRemoveNode((UINT64 *)PageRoot, (INT64 *)Root);
    if( v6 == 1 && MiFreePartitionNodePages((UINT64)TargetPartition, (INT64)Root, v7) < 0 )
      break;
    ExFreePoolWithTag((PVOID)Root[1].ParentValue, 0);
    ExFreePoolWithTag(Root, 0);
    Root = PageRoot->Root;
  }
  v10 = PageRoot->Root;
  if( !PageRoot->Root )
    goto LABEL_11;
  while( ((unsigned __int64)Root[1].Children[0] & 0x7FFFFFFFFFFFFFFFi64) < ((unsigned __int64)v10[1].Children[0] & 0x7FFFFFFFFFFFFFFFi64) )
  {
    v11 = v10->Children[0];
    if( !v10->Children[0] )
      goto LABEL_11;
LABEL_13:
    v10 = v11;
  }
  v11 = v10->Children[1];
  if( v11 )
    goto LABEL_13;
  v5 = 1;
LABEL_11:
  RtlAvlInsertNodeEx(&PageRoot->Root, (UINT64)v10, v5, Root);
}

Referenced by:

MiAllocatePartitionPhysicalPages
MiClearPartitionPageBitMap
MiHotAddPartitionMemory
MiInsertPartitionPages