EtwpEnqueueAvailableBuffer

VOID __fastcall EtwpEnqueueAvailableBuffer(INT64 a1, UINT64 *a2, UINT64 a3){
  ULONG_PTR BugCheckParameter4; 
  ULONG_PTR v5; 
  int v6; 
  UINT64 *v8; 
  UINT64 **v9; 
  UINT64 *v10; 
  UINT64 **v11; 
  int v12; 
  int v13; 
  UINT8 v14; 
  BugCheckParameter4 = *(unsigned int *)a2;
  v5 = *(unsigned int *)(a1 + 4);
  v6 = a3;
  v14 = 0;
  if( (_DWORD)v5 != (_DWORD)BugCheckParameter4 )
    KeBugCheckEx(0x11Du, 7ui64, (ULONG_PTR)a2, v5, BugCheckParameter4);
  *((_DWORD *)a2 + 11) = a3;
  a2[3] = _InterlockedIncrement64((volatile signed __int64 *)(a1 + 824));
  EtwpLockBufferList(a1, &v14);
  if( (*(_DWORD *)(a1 + 12) & 0x4000000) == 0
    || (v9 = (UINT64 **)(a1 + 72), (v10 = *(UINT64 **)(a1 + 72)) == 0i64)
    || v6 == 4 )
  {
    v8 = a2 + 4;
    goto LABEL_4;
  }
  if( v6 )
  {
    v11 = 0i64;
    do
    {
      v12 = *((_DWORD *)v10 + 3);
      if( (!v11 && (v13 = *((_DWORD *)v10 + 3), v12) || (v13 = *((_DWORD *)v10 + 3), v12 == 6)) && (v11 = v9, v13 == 6) )
      {
        *v9 = (UINT64 *)*v10;
        if( *v10 )
          *v10 = 0i64;
        else
          *(_QWORD *)(a1 + 64) = v9;
        *v10 = *(_QWORD *)(a1 + 1168);
        *(_QWORD *)(a1 + 1168) = v10;
      }
      else
      {
        v9 = (UINT64 **)v10;
      }
      v10 = *v9;
    }
    while( *v9 );
    v8 = a2 + 4;
    if( v11 )
    {
      *v8 = (UINT64)*v11;
      *v11 = v8;
      if( v11 != *(UINT64 ***)(a1 + 64) )
        goto LABEL_6;
      goto LABEL_5;
    }
LABEL_4:
    *v8 = 0i64;
    **(_QWORD **)(a1 + 64) = v8;
LABEL_5:
    *(_QWORD *)(a1 + 64) = v8;
    goto LABEL_6;
  }
  a2[4] = *(_QWORD *)(a1 + 72);
  *(_QWORD *)(a1 + 72) = a2 + 4;
  if( a1 + 72 == *(_QWORD *)(a1 + 64) )
    *(_QWORD *)(a1 + 64) = a2 + 4;
LABEL_6:
  EtwpUnlockBufferList(a1, &v14);
  _InterlockedIncrement((volatile signed __int32 *)(a1 + 244));
}

Referenced by:

EtwpAllocateFreeBuffers
EtwpCompleteBuffer
EtwpPrepareDirtyBuffer
EtwpRelinquishCompressionTarget
EtwpRotateCompressionTarget
EtwpSwitchBuffer