SmcStorePlacementGet

__int64 __fastcall SmcStorePlacementGet(__int64 a1, ULONG a2, __int64 a3){
  unsigned int v3; 
  unsigned __int64 v6; 
  unsigned __int64 v7; 
  unsigned __int64 v8; 
  _DWORD *v9; 
  _DWORD *v10; 
  unsigned __int64 v11; 
  unsigned __int64 v12; 
  unsigned int SetBits; 
  unsigned int v14; 
  unsigned int v15; 
  int v16; 
  int v17; 
  struct _RTL_BITMAP BitMapHeader; 
  v3 = 0;
  BitMapHeader.SizeOfBitMap = *(_DWORD *)(a1 + 8);
  *(&BitMapHeader.SizeOfBitMap + 1) = 0;
  v6 = ((unsigned __int64)BitMapHeader.SizeOfBitMap + 31) >> 5;
  v7 = a1 + 168;
  BitMapHeader.Buffer = *(unsigned int **)(a3 + 8);
  v8 = v7 + 384;
  while( v7 < v8 )
  {
    if( v7 != a3 )
    {
      v9 = *(_DWORD **)(v7 + 8);
      if( v9 )
      {
        v10 = *(_DWORD **)(a3 + 8);
        v11 = v6;
        v12 = 0i64;
        if( v9 > &v9[v6] )
          v11 = 0i64;
        if( v11 )
        {
          do
          {
            ++v12;
            *v10++ ^= *v9++;
          }
          while( v12 < v11 );
        }
      }
    }
    v7 += 24i64;
  }
  SetBits = RtlFindSetBits(&BitMapHeader, a2, 0i64);
  v14 = SetBits;
  if( SetBits == -1 )
  {
    v16 = 0;
    v17 = RtlFindSetBits(&BitMapHeader, 1ui64, 0i64);
    if( v17 < 0 )
      return(unsigned int)-1073741697;
    while( 1 )
    {
      ++v16;
      v15 = v17 + 1;
      if( v16 == a2 )
        break;
      v17 = RtlFindSetBits(&BitMapHeader, 1ui64, v15);
      if( v17 < (int)v15 )
        return(unsigned int)-1073741697;
    }
  }
  else
  {
    RtlClearBits(&BitMapHeader, 0i64, SetBits);
    v15 = a2 + v14;
  }
  RtlClearBits(&BitMapHeader, v15, BitMapHeader.SizeOfBitMap - v15);
  return v3;
}

Referenced by:

SmcStoreResize
SmcStoreSlotReserve