RtlCSparseBitmapBitmaskWrite

NTSTATUS __stdcall RtlCSparseBitmapBitmaskWrite(INT64 a1, UINT64 a2, INT64 a3, INT64 a4){
  int v7; 
  __int64 v8; 
  UINT64 v9; 
  char v10; 
  UINT64 v11; 
  INT64 v12; 
  signed __int64 v13; 
  __int64 v14; 
  signed __int64 i; 
  INT64 v17[2]; 
  __int128 v18; 
  UINT8 v19[16]; 

  *(_OWORD *)v17 = 0i64;
  v18 = 0i64;
  if( a4 )
  {
    v7 = RtlpCSparseBitmapPageCommit(a1, a2 >> 15, v17, &v18);
    if( v7 >= 0 )
    {
      v8 = *(_QWORD *)(a1 + 8);
      v9 = a2;
      v10 = a2 & 0x3F;
      v11 = v9 >> 6;
      v12 = a4 << v10;
      v13 = *(_QWORD *)(v8 + 8 * v11);
      v14 = v13 & ~(3i64 << v10);
      for( i = v13; ; v14 = i & ~(3i64 << v10) )
      {
        i = _InterlockedCompareExchange64((volatile signed __int64 *)(v8 + 8 * v11), v12 | v14, i);
        if( v13 == i )
          break;
        v13 = i;
      }
      v7 = 0;
      RtlpCSparseBitmapUnlock(v17);
      *(_OWORD *)v19 = v18;
      RtlCSparseBitmapLeaveLockingRegion(v19);
    }
    return v7;
  }
  else
  {
    RtlCSparseBitmapBitsClear(a1, a2, 2i64);
    return 0;
  }
}

Referenced by:

RtlpHpSegSegmentAllocate