KiAbEntryUpdateWaiterTreePosition

VOID __fastcall KiAbEntryUpdateWaiterTreePosition(SLIST_ENTRY *RunRef){
  __int64 v1; 
  char v3; 
  __int64 v4; 
  bool v5; 
  unsigned __int64 v6; 
  unsigned __int64 v7; 
  v3 = BYTE3(RunRef[-*((unsigned __int8 *)&RunRef[1].Next + 8) + 12].Next);
  if( v3 > 15 )
    v3 = 15;
  if( LOBYTE(RunRef[3].Next) != v3 )
  {
    v4 = v1 + 64;
    LOBYTE(RunRef[3].Next) = v3;
    RtlRbRemoveNode((unsigned __int64 *)(v1 + 64), (unsigned __int64)RunRef);
    v5 = 0;
    v6 = *(_QWORD *)v4;
    if( (*(_BYTE *)(v4 + 8) & 1) != 0 )
    {
      if( v6 )
        v6 ^= v4;
      else
        v6 = 0i64;
    }
    if( v6 )
    {
      while( 1 )
      {
        if( *(_BYTE *)(v6 + 48) < SLOBYTE(RunRef[3].Next) )
        {
          v7 = *(_QWORD *)v6;
          if( (*(_BYTE *)(v4 + 8) & 1) != 0 )
          {
            if( !v7 )
              break;
            v7 ^= v6;
          }
          if( !v7 )
            break;
        }
        else
        {
          v7 = *(_QWORD *)(v6 + 8);
          if( (*(_BYTE *)(v4 + 8) & 1) != 0 )
          {
            if( !v7 )
              goto LABEL_11;
            v7 ^= v6;
          }
          if( !v7 )
          {
LABEL_11:
            v5 = 1;
            break;
          }
        }
        v6 = v7;
      }
    }
    RtlRbInsertNodeEx((unsigned __int64 *)v4, v6, v5, (unsigned __int64)RunRef);
  }
}

Referenced by:

KiAbForceProcessLockEntry
KiAbProcessContextSwitch
KiAbProcessThreadLocks