KiReadGuestSchedulerAssistPriority

INT64 __fastcall KiReadGuestSchedulerAssistPriority(INT64 a1){
  int *v1; 
  int v3; 
  int v4; 
  int v5; 
  v1 = *(int **)(a1 + 968);
  if( !v1 )
    return(unsigned int)*(char *)(a1 + 195);
  v3 = *v1;
  if( (*v1 & 0x20000) == 0 )
  {
    v4 = BYTE1(v3);
    if( (unsigned int)BYTE1(v3) - 1 > 0x1E )
      v4 = 1;
    if( (KiVelocityFlags & 1) != 0 )
      goto LABEL_16;
    if( (KiVelocityFlags & 8) != 0 )
    {
      v4 += PsPrioritySeparation;
      if( v4 >= 16 )
        v4 = 15;
      goto LABEL_16;
    }
    v5 = *(char *)(a1 + 563);
    if( v4 >= v5 )
    {
      if( (unsigned int)v4 < 0x10 )
        goto LABEL_16;
      v5 = v4;
      if( (KiVelocityFlags & 0x80u) == 0 )
        v5 = 15;
    }
    v4 = v5;
LABEL_16:
    if( v1[7] && v4 < (int)KiVpThreadSystemWorkPriority )
      v4 = KiVpThreadSystemWorkPriority;
    if( v1[8] && v4 < (int)KiVpThreadSystemWorkPriority )
      v4 = KiVpThreadSystemWorkPriority;
    if( (KiVelocityFlags & 0x20) != 0 && v1[6] && v4 < (int)KiVpThreadSystemWorkPriority )
      v4 = KiVpThreadSystemWorkPriority;
    if( (KiVelocityFlags & 0x200) != 0 && v1[5] && v4 < (int)KiVpThreadSystemWorkPriority )
      v4 = KiVpThreadSystemWorkPriority;
    if( (KiVelocityFlags & 0x40) != 0 && (v3 & 0x80000) != 0 && v4 < (int)KiVpThreadSystemWorkPriority )
      return(unsigned int)KiVpThreadSystemWorkPriority;
    return(unsigned int)v4;
  }
  return 7;
}

Referenced by:

KiAddThreadToPrcbQueue
KiDeferredReadySingleThread
KiDirectSwitchThread
KiQuantumEnd
KiQueueReadyThread
KiUpdateVPBackingThreadPriority
KiUpdateVpBackingThreadPriorityFromTopLevel