VslpFlushBufferArray

NTSTATUS __stdcall VslpFlushBufferArray(){
  unsigned __int64 PoolWithTag; 
  unsigned int v1; 
  __int64 v2; 
  unsigned int v3; 
  unsigned __int64 *v4; 
  bool v5; 
  __int64 v6; 
  unsigned int v7; 
  int v8; 
  INT64 v9; 
  __int64 v10; 
  UINT64 v11; 
  VOID *v13; 
  VOID *v14; 
  VOID *v15; 

  LODWORD(PoolWithTag) = *(&stru_140C452E0 + 1920);
  v1 = 0;
  v2 = *(unsigned int *)(*(&stru_140C452E0 + 960) + 8i64);
  v3 = **(&stru_140C452E0 + 960);
  v4 = (unsigned __int64 *)(*(&stru_140C452E0 + 960) + 24i64 + 8 * v2);
  if( (_DWORD)v2 )
  {
    do
    {
      PoolWithTag = *v4;
      v5 = !_BitScanForward64((unsigned __int64 *)&v6, *v4);
      if( !v5 )
      {
        v7 = v1 << 6;
        do
        {
          v8 = v7 + v6;
          if( v7 + (unsigned int)v6 >= v3 )
            break;
          if( _interlockedbittestandreset64((volatile signed __int32 *)v4, (unsigned int)v6) == 1 )
          {
            PoolWithTag = (unsigned __int64)ExAllocatePoolWithTag(0x200ui64, 0x10ui64, 1416850774i64);
            v9 = PoolWithTag;
            if( !PoolWithTag )
              return PoolWithTag;
            v10 = *(&stru_140C452E0 + 960);
            *(_DWORD *)PoolWithTag = v8;
            *(_QWORD *)(PoolWithTag + 8) = 16i64 * *(unsigned int *)(v10 + 8)
                                         + 24
                                         + v10
                                         + (unsigned int)(v8 * *(_DWORD *)(v10 + 4));
            ExAcquireRundownProtection((_EX_RUNDOWN_REF *)&stru_140C452E0 + 956);
            v11 = *(&stru_140C452E0 + 959);
            *(_WORD *)(*(_QWORD *)(v9 + 8) + 42i64) = *(&stru_140C452E0 + 3836);
            if( EtwSendTraceBuffer(v11, *(VOID **)(v9 + 8), 0i64, VslpFlushBufferArrayEntryCallback, v9, v13, v14, v15) < 0 )
              ExReleaseRundownProtection((_EX_RUNDOWN_REF *)&stru_140C452E0 + 956);
          }
          PoolWithTag = *v4;
          v5 = !_BitScanForward64((unsigned __int64 *)&v6, *v4);
        }
        while( !v5 );
      }
      ++v1;
      ++v4;
    }
    while( v1 < (unsigned int)v2 );
  }
  return PoolWithTag;
}

Referenced by:

VslpSkFlushBufferCallback
VslpSkStopProfiling