MiAddMdlToPartitionTree

NTSTATUS __stdcall MiAddMdlToPartitionTree(_RTL_BALANCED_NODE **Tree, INT64 a2, CHAR a3){
  unsigned __int64 v3; 
  _BOOL4 v4; 
  UINT64 v5; 
  UINT64 v6; 
  __int64 v8; 
  _RTL_AVL_TREE *v9; 
  NTSTATUS v10; 
  __int64 v11; 
  int v13; 

  v3 = (unsigned __int64)*(unsigned int *)(a2 + 40) >> 12;
  v4 = (a3 & 1) == 0;
  v5 = 0i64;
  v6 = -1i64;
  v8 = 0i64;
  v9 = (_RTL_AVL_TREE *)Tree;
  v10 = 1;
  do
  {
    v11 = (unsigned int)v8;
    if( (unsigned int)v8 == v3 )
    {
      if( !v5 )
        return v10;
LABEL_4:
      if( v10 )
      {
        MiAddRangeToPartitionTree(v9, v6, v5, v4);
        if( !v13 )
        {
          LODWORD(v8) = -1;
          v3 = v11 - v5;
          v5 = 0i64;
          v10 = 0;
LABEL_8:
          v9 = (_RTL_AVL_TREE *)Tree;
          goto LABEL_9;
        }
      }
      else
      {
        MiClearRangeInPartitionTree(&v9->Root, v6, v5);
      }
      if( (unsigned int)v8 == v3 )
        return v10;
      v5 = 0i64;
      LODWORD(v8) = v8 - 1;
      goto LABEL_8;
    }
    if( v5 )
    {
      v9 = (_RTL_AVL_TREE *)Tree;
      if( *(_QWORD *)(a2 + 8 * v8 + 40) + 1i64 != *(_QWORD *)(a2 + 8 * v8 + 48) )
        goto LABEL_4;
      ++v5;
    }
    else
    {
      v6 = *(_QWORD *)(a2 + 8 * v8 + 48);
      v5 = 1i64;
    }
LABEL_9:
    v8 = (unsigned int)(v8 + 1);
  }
  while( (unsigned int)v8 <= v3 );
  return v10;
}

Referenced by:

MiAllocatePartitionPhysicalPages