MiReturnPoolCharges

VOID __fastcall MiReturnPoolCharges(UINT64 *a1, INT64 a2){
  int v2; 
  struct _KPRCB *CurrentPrcb; 
  unsigned __int64 v5; 
  __int64 v6; 
  bool v7; 
  signed __int32 v8; 
  unsigned __int64 v9; 
  v2 = a2;
  if( qword_140C52868 )
  {
    CurrentPrcb = KeGetCurrentPrcb();
    v5 = *a1;
    v6 = *((int *)CurrentPrcb + 8391);
    if( (_DWORD)v6 != -1 )
    {
      if( v5 + v6 <= 0x100 )
      {
        do
        {
          if( v5 >= 0x80000 )
            break;
          v8 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, v6 + v5, v6);
          v7 = (_DWORD)v6 == v8;
          LODWORD(v6) = v8;
          if( v7 )
            goto LABEL_6;
        }
        while( v8 != -1 && v5 + v8 <= 0x100 );
      }
      if( (int)v6 > 192
        && (_DWORD)v6 != -1
        && (_DWORD)v6 == _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, 192, v6) )
      {
        v5 += (int)v6 - 192;
      }
    }
    if( v5 )
      _InterlockedExchangeAdd64(&qword_140C526C0, v5);
LABEL_6:
    MiReturnCommit((_MI_PARTITION *)&MiSystemPartition, a1[3] - a1[1]);
    if( v2 != 2 )
    {
      v9 = -(__int64)a1[3];
      if( v2 )
        _InterlockedExchangeAdd64(&qword_140C4ECE8, v9);
      else
        _InterlockedExchangeAdd64(&qword_140C4ECE0, v9);
    }
  }
}

Referenced by:

MiGetPoolPages
MiInitializePoolCommitPacket
MiReturnExcessPoolCommit
MiReturnPhysicalPoolPages
MmAllocateIndependentPagesEx
MmFreeIndependentPages