KiAbEntryUpdateOwnerTreePosition

VOID __stdcall KiAbEntryUpdateOwnerTreePosition(_KLOCK_ENTRY *Entry, _KLOCK_ENTRY *HeadEntry){
  char v4; 
  $7B2E770ECE9D41F9BAF2C76B9605F18D *v5; 
  BOOL v6; 
  UINT64 Root; 
  UINT64 v8; 

  v4 = KiAbOwnerComputeCpuPriorityKey(Entry);
  if( Entry->CpuPriorityKey != v4 )
  {
    v5 = &HeadEntry->48;
    Entry->CpuPriorityKey = v4;
    RtlRbRemoveNode((UINT64 *)v5, (UINT64)Entry);
    v6 = 0;
    Root = (UINT64)v5->OwnerTree.Root;
    if( (v5->OwnerTree._bf_0 & 1) != 0 )
    {
      if( Root )
        Root ^= (unsigned __int64)v5;
      else
        Root = 0i64;
    }
    if( Root )
    {
      while( 1 )
      {
        if( *(_BYTE *)(Root + 48) > Entry->CpuPriorityKey )
        {
          v8 = *(_QWORD *)Root;
          if( (v5->OwnerTree._bf_0 & 1) != 0 )
          {
            if( !v8 )
              break;
            v8 ^= Root;
          }
          if( !v8 )
            break;
        }
        else
        {
          v8 = *(_QWORD *)(Root + 8);
          if( (v5->OwnerTree._bf_0 & 1) != 0 )
          {
            if( !v8 )
              goto LABEL_9;
            v8 ^= Root;
          }
          if( !v8 )
          {
LABEL_9:
            v6 = 1;
            break;
          }
        }
        Root = v8;
      }
    }
    RtlRbInsertNodeEx((UINT64 *)v5, Root, v6, (UINT64)Entry);
  }
}

Referenced by:

KiAbProcessContextSwitch
KiAbProcessThreadLocks