RtlpHpLfhSubsegmentDecBlockCounts

NTSTATUS __stdcall RtlpHpLfhSubsegmentDecBlockCounts(INT64 a1, INT64 a2, UINT64 a3, INT64 a4){
  char v6; 
  __int64 v7; 
  __int64 v8; 
  char *v9; 
  int v10; 
  char *v11; 
  int v12; 
  signed __int16 v13; 

  v6 = *(_BYTE *)(a2 + 44);
  v7 = (unsigned int)a3 >> v6;
  v8 = 2 * v7;
  v9 = (char *)(2 * v7 + a2 + *(unsigned __int16 *)(a2 + 46));
  _m_prefetchw(v9);
  v10 = ((unsigned int)(a3 + a4 - 1) >> v6) - v7;
  LODWORD(a3) = -1;
  v11 = &v9[2 * (v10 + 1)];
  v12 = 0;
  if( v9 < v11 )
  {
    do
    {
      v13 = _InterlockedDecrement16((volatile signed __int16 *)v9);
      if( v13 )
      {
        if( v13 == -1 )
          --v12;
      }
      else
      {
        ++v12;
        if( (_DWORD)a3 == -1 )
          a3 = v8 >> 1;
      }
      v9 += 2;
      v8 += 2i64;
    }
    while( v9 < v11 );
    if( v12 && (RtlpHpLfhPerfFlags & 0x20) != 0 )
      _InterlockedExchangeAdd64(
        (volatile signed __int64 *)(*(__int16 *)(a1 + 58) + a1 + 24),
        (v12 << *(_BYTE *)(a2 + 44)) / 4096);
  }
  return a3;
}

Referenced by:

RtlpHpLfhSlotAllocate
RtlpHpLfhSubsegmentDecommitPages