KiGetComparisonRanks

VOID __stdcall KiGetComparisonRanks(_KSCB *Scb, _KSCB *NewScb, UINT64 *Rank, UINT64 *NewRank){
  _KSCB *v6; 
  unsigned int v7; 
  unsigned int v8; 
  unsigned __int8 Depth; 
  char v10; 
  unsigned __int8 v11; 
  _KSCB *Parent; 
  _KSCB *v13; 
  unsigned int v14; 
  unsigned int v15; 

  v6 = Scb;
  if( Scb == NewScb )
  {
    v7 = Scb->Rank;
    v8 = v7;
    goto LABEL_3;
  }
  Depth = Scb->Depth;
  v10 = 0;
  v11 = NewScb->Depth;
  v7 = 0;
  if( Depth > v11 )
  {
    v10 = 1;
    do
    {
      v14 = v7;
      v7 = v6->Rank;
      v6 = v6->Parent;
      if( v7 <= v14 )
        v7 = v14;
    }
    while( v6->Depth > v11 );
  }
  else if( Depth < v11 )
  {
    v10 = -1;
    do
    {
      v15 = v7;
      v7 = NewScb->Rank;
      NewScb = NewScb->Parent;
      if( v7 <= v15 )
        v7 = v15;
    }
    while( Depth < NewScb->Depth );
  }
  v8 = v7;
  if( v6 != NewScb )
  {
    Parent = v6->Parent;
    v10 = 0;
    v13 = NewScb->Parent;
    if( Parent == v13 )
    {
LABEL_8:
      v7 = NewScb->Rank;
      v8 = v6->Rank;
      goto LABEL_3;
    }
    do
    {
      v6 = Parent;
      NewScb = v13;
      Parent = Parent->Parent;
      v13 = v13->Parent;
    }
    while( Parent != v13 );
  }
  if( !v10 )
    goto LABEL_8;
  if( v10 <= 0 )
    v8 = 0;
  else
    v7 = 0;
LABEL_3:
  *(_DWORD *)Rank = v8;
  *(_DWORD *)NewRank = v7;
}

Referenced by:

KiDirectSwitchThread
KiEvaluateGroupSchedulingPreemption