EtwpCovSampStackHashCheck

NTSTATUS __stdcall EtwpCovSampStackHashCheck(INT64 *a1, INT64 a2, UINT8 *a3, INT64 a4){
  __int64 v7; 
  NTSTATUS v8; 
  _DWORD *v9; 
  INT64 v10; 
  __int64 v11; 
  __int64 v12; 
  __int64 v13; 
  int v14; 
  int v15; 
  int v16; 
  int v17; 
  int v18; 
  int v19; 
  unsigned int v20; 
  int v21; 
  unsigned int v22; 
  volatile signed __int32 *v23; 

  v23 = 0i64;
  if( !a1[118] )
    return 0;
  v7 = a1[118];
  v8 = 0;
  v9 = (_DWORD *)a1[119];
  if( (_DWORD *)v7 == v9 )
    v9 = (_DWORD *)a1[120];
  v10 = a1[121];
  a4 = (unsigned int)a4;
  v11 = 8i64 * (unsigned int)a4;
  if( (unsigned __int64)v11 >= 8 )
  {
    v11 = 0i64;
    do
    {
      v12 = a3[6] + 37 * (a3[5] + 37 * (a3[4] + 37 * (a3[3] + 37 * (a3[2] + 37 * (a3[1] + 37 * (*a3 + 37 * v10))))));
      v13 = a3[7];
      a3 += 8;
      v10 = v13 + 37 * v12;
      --a4;
    }
    while( a4 );
  }
  if( v11 >= 1 )
  {
    v14 = v11 - 1;
    if( !v14 )
    {
LABEL_22:
      LODWORD(v10) = *a3 + 37 * v10;
      goto LABEL_23;
    }
    v15 = v14 - 1;
    if( !v15 )
    {
LABEL_21:
      LODWORD(v10) = *a3++ + 37 * v10;
      goto LABEL_22;
    }
    v16 = v15 - 1;
    if( !v16 )
    {
LABEL_20:
      LODWORD(v10) = *a3++ + 37 * v10;
      goto LABEL_21;
    }
    v17 = v16 - 1;
    if( !v17 )
    {
LABEL_19:
      LODWORD(v10) = *a3++ + 37 * v10;
      goto LABEL_20;
    }
    v18 = v17 - 1;
    if( !v18 )
    {
LABEL_18:
      LODWORD(v10) = *a3++ + 37 * v10;
      goto LABEL_19;
    }
    v19 = v18 - 1;
    if( !v19 )
    {
LABEL_17:
      LODWORD(v10) = *a3++ + 37 * v10;
      goto LABEL_18;
    }
    if( v19 == 1 )
    {
      LODWORD(v10) = *a3++ + 37 * v10;
      goto LABEL_17;
    }
  }
LABEL_23:
  if( (unsigned int)EtwpCovSampStackHashLookup(v7, v10, &v23) )
    return 1;
  v20 = (unsigned int)(7 * *(_DWORD *)(v7 + 4)) >> 3;
  if( *(_DWORD *)v7 <= v20 )
  {
    v21 = 0;
    v22 = _InterlockedIncrement((volatile signed __int32 *)v7);
    if( v22 == v20 )
      v21 = 1;
    if( v22 < (unsigned int)(7 * *(_DWORD *)(v7 + 4)) >> 3 )
    {
      while( _InterlockedCompareExchange(v23, v10, 0) )
      {
        if( (unsigned int)EtwpCovSampStackHashLookup(v7, v10, &v23) )
        {
          v8 = 1;
          goto LABEL_34;
        }
      }
      if( (unsigned int)EtwpCovSampStackHashLookup((__int64)v9, v10, &v23) )
        v8 = 1;
    }
LABEL_34:
    if( v21 )
    {
      memset(v9 + 2, 0i64, 4 * v9[1]);
      *v9 = 0;
      _InterlockedExchange64(a1 + 118, (__int64)v9);
    }
  }
  return v8;
}

Referenced by:

EtwpCovSampCaptureBufferMapAddressesAndQueue
EtwpCovSampCaptureBufferProcess
EtwpCovSampSampleBufferProcess