EtwpReleaseTraceBuffer

UINT64 __fastcall EtwpReleaseTraceBuffer(INT64 *a1){
  INT64 v1; 
  _QWORD *v2; 
  UINT64 result; 
  UINT64 v4; 
  v1 = *a1;
  v2 = (_QWORD *)a1[1];
  _m_prefetchw(v2);
  result = *v2;
  if( ((unsigned __int64)v1 ^ *v2) >= 0xF )
  {
LABEL_4:
    result = *a1;
    _InterlockedDecrement((volatile signed __int32 *)(*a1 + 12));
  }
  else
  {
    while( 1 )
    {
      v4 = result;
      result = _InterlockedCompareExchange64(v2, result + 1, result);
      if( v4 == result )
        break;
      if( (v1 ^ result) >= 0xF )
        goto LABEL_4;
    }
  }
  return result;
}

Referenced by:

EtwTraceEvent
EtwTraceRaw
EtwpEventWriteFull
EtwpFailLogging
EtwpLogContextSwapEvent
EtwpLogSystemEventUnsafe
EtwpTraceMessageVa
EtwpWriteUserEvent