MiReduceMappedFileReadBehind

NTSTATUS __stdcall MiReduceMappedFileReadBehind(PRTL_BITMAP BitMapHeader, UINT32 StartingIndex){
  int v2; 
  int v3; 
  NTSTATUS v4; 
  unsigned int v7; 
  unsigned int SizeOfBitMap; 
  unsigned int *Buffer; 
  unsigned int *v10; 
  unsigned int *v11; 
  unsigned int v12; 
  int v13; 
  unsigned int i; 
  unsigned int v16; 
  unsigned int *v17; 
  v3 = v2;
  v4 = 0;
  RtlSetBits(BitMapHeader, *(UINT64 *)&StartingIndex, 1ui64);
  v7 = 0;
  if( StartingIndex )
  {
    while( 1 )
    {
      SizeOfBitMap = BitMapHeader->SizeOfBitMap;
      if( BitMapHeader->SizeOfBitMap <= v7 )
        goto LABEL_20;
      Buffer = BitMapHeader->Buffer;
      v10 = &Buffer[(unsigned __int64)(SizeOfBitMap - 1) >> 5];
      v11 = &Buffer[(unsigned __int64)v7 >> 5];
      if( v11 != v10 && (*v11 | *((_DWORD *)qword_140011CE0 + (v7 & 0x1F))) == -1 )
      {
        v7 = v7 - (v7 & 0x1F) + 32;
        for( ++v11; v11 < v10 && *v11 == -1; ++v11 )
          v7 += 32;
      }
      for( ; v7 < SizeOfBitMap; ++v7 )
      {
        if( !_bittest((const signed __int32 *)BitMapHeader->Buffer, v7) )
          break;
      }
      v12 = 0;
      if( v11 == v10 )
        goto LABEL_14;
      v13 = v7 & 0x1F;
      if( (*v11 & ~*((_DWORD *)qword_140011CE0 + (v7 & 0x1F))) != 0 )
        goto LABEL_14;
      v12 = 32 - v13;
      if( v13 != 33 )
        break;
LABEL_18:
      if( v12 && v7 < StartingIndex )
      {
        v16 = v3 - v4;
        if( v12 <= v3 - v4 )
          v16 = v12;
        RtlSetBits(BitMapHeader, v7, v16);
        v4 += v16;
        if( v4 != v3 )
        {
          v7 += v16;
          if( v7 < StartingIndex )
            continue;
        }
      }
      goto LABEL_20;
    }
    v17 = v11 + 1;
    while( v17 < v10 && !*v17 )
    {
      ++v17;
      v12 += 32;
      if( v12 == -1 )
        goto LABEL_18;
    }
LABEL_14:
    for( i = v12 + v7; i < BitMapHeader->SizeOfBitMap; ++v12 )
    {
      if( _bittest((const signed __int32 *)BitMapHeader->Buffer, i) )
        break;
      if( v12 == -1 )
        break;
      ++i;
    }
    goto LABEL_18;
  }
LABEL_20:
  RtlClearBits(BitMapHeader, StartingIndex, 1ui64);
  return v4;
}

Referenced by:

MiBuildMdlForMappedFileFault