ViDeadlockRemoveThread

VOID __fastcall ViDeadlockRemoveThread(_VI_DEADLOCK_THREAD *Thread, UINT64 DisableConsistencyChecks){
  _QWORD *v3; 
  _LIST_ENTRY *Flink; 
  _LIST_ENTRY *Blink; 
  unsigned __int64 v6; 
  unsigned __int64 v7; 
  unsigned __int64 v8; 
  if( *((_DWORD *)ViDeadlockGlobals + 8196) || *((int *)ViDeadlockGlobals + 8282) > 1024 )
    LODWORD(DisableConsistencyChecks) = 1;
  if( !(_DWORD)DisableConsistencyChecks && Thread->NodeCount )
  {
    ViDeadlockPreprocessOptions(
      &byte_140C12D80,
      "Terminated thread 0x%p owns lock.",
      0x100Aui64,
      (UINT64)Thread->Thread,
      (UINT64)Thread,
      0i64);
    VfReportIssueWithOptions(0xC4ui64, 0x100Aui64, (UINT64)Thread->Thread, (UINT64)Thread, 0i64, &byte_140C12D80);
  }
  v3 = ViDeadlockGlobals;
  --*((_QWORD *)ViDeadlockGlobals + 2051);
  Flink = Thread->ListEntry.Flink;
  if( ($92CCD2AF59176F619141B6C8F8B2A616 *)Flink->Blink != &Thread->24
    || (Blink = Thread->ListEntry.Blink, ($92CCD2AF59176F619141B6C8F8B2A616 *)Blink->Flink != &Thread->24) )
  {
    __fastfail(3u);
  }
  Blink->Flink = Flink;
  Flink->Blink = Blink;
  v6 = (unsigned __int64)Thread->Thread >> 12;
  v7 = 16 * (v6 % 0x3FF);
  v8 = 2 * (v6 % 0x3FF + 1026);
  if( *(_QWORD *)(v7 + v3[2050]) == v7 + v3[2050] )
  {
    v3[v8] = 0i64;
    v3[v8 + 1] = 0i64;
  }
  else
  {
    VfUtilAddressRangeRemove(&v3[v8], (__int64)Thread->Thread, 2200i64);
  }
}

Referenced by:

VfDeadlockAcquireResource
VfDeadlockReleaseResource
ViDeadlockEmptyDatabase
ViDeadlockRemoveMemoryRangeThreads