EtwpCovSampStackHashCheck

INT64 __fastcall EtwpCovSampStackHashCheck(INT64 *a1, INT64 a2, UINT8 *r8_0, INT64 a4){
  INT64 v7; 
  unsigned int 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 *a3; 
  a3 = 0i64;
  if( !a1[118] )
    return 0i64;
  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 = r8_0[6]
          + 37 * (r8_0[5] + 37 * (r8_0[4] + 37 * (r8_0[3] + 37 * (r8_0[2] + 37 * (r8_0[1] + 37 * (*r8_0 + 37 * v10))))));
      v13 = r8_0[7];
      r8_0 += 8;
      v10 = v13 + 37 * v12;
      --a4;
    }
    while( a4 );
  }
  if( v11 >= 1 )
  {
    v14 = v11 - 1;
    if( !v14 )
    {
LABEL_22:
      LODWORD(v10) = *r8_0 + 37 * v10;
      goto LABEL_23;
    }
    v15 = v14 - 1;
    if( !v15 )
    {
LABEL_21:
      LODWORD(v10) = *r8_0++ + 37 * v10;
      goto LABEL_22;
    }
    v16 = v15 - 1;
    if( !v16 )
    {
LABEL_20:
      LODWORD(v10) = *r8_0++ + 37 * v10;
      goto LABEL_21;
    }
    v17 = v16 - 1;
    if( !v17 )
    {
LABEL_19:
      LODWORD(v10) = *r8_0++ + 37 * v10;
      goto LABEL_20;
    }
    v18 = v17 - 1;
    if( !v18 )
    {
LABEL_18:
      LODWORD(v10) = *r8_0++ + 37 * v10;
      goto LABEL_19;
    }
    v19 = v18 - 1;
    if( !v19 )
    {
LABEL_17:
      LODWORD(v10) = *r8_0++ + 37 * v10;
      goto LABEL_18;
    }
    if( v19 == 1 )
    {
      LODWORD(v10) = *r8_0++ + 37 * v10;
      goto LABEL_17;
    }
  }
LABEL_23:
  if( (unsigned int)EtwpCovSampStackHashLookup(v7, (unsigned int)v10, &a3) )
  {
    return 1;
  }
  else
  {
    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(a3, v10, 0) )
        {
          if( (unsigned int)EtwpCovSampStackHashLookup(v7, (unsigned int)v10, &a3) )
          {
            v8 = 1;
            goto LABEL_34;
          }
        }
        if( (unsigned int)EtwpCovSampStackHashLookup((INT64)v9, (unsigned int)v10, &a3) )
          v8 = 1;
      }
LABEL_34:
      if( v21 )
      {
        memset((INT64)(v9 + 2), 0i64);
        *v9 = 0;
        _InterlockedExchange64(a1 + 118, (__int64)v9);
      }
    }
  }
  return v8;
}

Referenced by:

EtwpCovSampCaptureBufferMapAddressesAndQueue
EtwpCovSampCaptureBufferProcess
EtwpCovSampSampleBufferProcess