MiReduceMdl

UINT64 __stdcall MiReduceMdl(MDL *Mdl){
  MDL *v1; 
  unsigned int v2; 
  __int64 ByteCount; 
  __int64 v4; 
  UINT64 v6; 
  MDL *v7; 
  unsigned int v8; 
  unsigned __int64 v9; 
  _MDL **v10; 
  unsigned int v12; 
  __int16 v13; 
  unsigned int v14; 
  unsigned int v15; 
  bool v16; 
  __int64 v17; 
  MDL *v18; 
  signed __int64 v19; 
  v1 = Mdl + 1;
  v2 = 0;
  ByteCount = Mdl->ByteCount;
  v4 = (LODWORD(Mdl->StartVa) + Mdl->ByteOffset) & 0xFFF;
  v6 = 0i64;
  v7 = Mdl + 1;
  v8 = 0;
  v9 = (unsigned __int64)(v4 + ByteCount + 4095) >> 12;
  if( v9 != 1 )
  {
    do
    {
      if( v7->Next != (_MDL *)qword_140C4EAB8 )
        break;
      ++v8;
      ++v6;
      v7 = (MDL *)((char *)v7 + 8);
    }
    while( v8 < v9 - 1 );
  }
  if( v6 )
  {
    Mdl->Size += -8 * v6;
    Mdl->ByteCount = ByteCount - ((_DWORD)v6 << 12);
    v19 = (char *)v1 - (char *)v7;
    do
    {
      ++v8;
      *(_MDL **)((char *)&v7->Next + v19) = v7->Next;
      v7 = (MDL *)((char *)v7 + 8);
    }
    while( v8 < v9 );
    v9 -= v6;
  }
  v10 = &Mdl->Next + v9;
  if( v10[5] == (_MDL *)qword_140C4EAB8 )
  {
    v12 = Mdl->ByteCount;
    v13 = v12;
    Mdl->Size -= 8;
    v14 = v12 - 4096;
    v15 = v12 & 0xFFFFF000;
    v16 = (v13 & 0xFFF) == 0;
    v17 = 0i64;
    if( v16 )
      v15 = v14;
    v18 = (MDL *)(v10 + 4);
    Mdl->ByteCount = v15;
    if( v18 != v1 )
    {
      do
      {
        if( v18->Next != (_MDL *)qword_140C4EAB8 )
          break;
        ++v17;
        v18 = (MDL *)((char *)v18 - 8);
      }
      while( v18 != v1 );
      if( v17 )
      {
        Mdl->Size -= 8 * v17;
        Mdl->ByteCount = v15 - ((_DWORD)v17 << 12);
      }
    }
    v9 += -1 - v17;
  }
  Mdl->MdlFlags |= 0x4000u;
  if( v9 )
  {
    while( v1->Next != (_MDL *)qword_140C4EAB8 )
    {
      ++v2;
      v1 = (MDL *)((char *)v1 + 8);
      if( v2 >= v9 )
        return v6;
    }
    Mdl->MdlFlags &= ~0x4000u;
  }
  return v6;
}

Referenced by:

MiPfPutPagesInTransition
MiResolvePageFileFault