RtlInterlockedClearBitRun

VOID __stdcall RtlInterlockedClearBitRun(RTL_BITMAP *BitMapHeader, UINT64 StartingIndex, UINT64 NumberToClear){
  unsigned int v3; 
  UINT64 v4; 
  volatile signed __int32 *v5; 
  int v6; 
  int v7; 
  unsigned __int64 v8; 
  v3 = NumberToClear;
  v4 = StartingIndex & 0x1F;
  v5 = (volatile signed __int32 *)&BitMapHeader->Buffer[(unsigned __int64)(unsigned int)StartingIndex >> 5];
  if( v4 + (unsigned int)NumberToClear <= 0x20 )
  {
    if( (_DWORD)NumberToClear == 32 )
    {
      *v5 = 0;
      return;
    }
    v6 = ~(((1 << NumberToClear) - 1) << v4);
    goto LABEL_4;
  }
  v7 = StartingIndex & 0x1F;
  if( (StartingIndex & 0x1F) != 0 )
  {
    _InterlockedAnd(v5, ~(((1 << (32 - v7)) - 1) << v4));
    v3 = NumberToClear - (32 - v7);
    ++v5;
  }
  if( v3 >= 0x20 )
  {
    v8 = (unsigned __int64)v3 >> 5;
    do
    {
      *v5 = 0;
      v3 -= 32;
      ++v5;
      --v8;
    }
    while( v8 );
  }
  if( v3 )
  {
    v6 = -1 << v3;
LABEL_4:
    _InterlockedAnd(v5, v6);
  }
}

Referenced by:

EtwpFreeUserBufferSpace
MiLogPinDriverAddressesWorker