HalpTimerFindIdealPerformanceCounterSource

ULONG_PTR *__stdcall HalpTimerFindIdealPerformanceCounterSource(){
  int v0; 
  ULONG_PTR *result; 

  if( HalpTimerPlatformSourceForced )
    goto LABEL_9;
  if( HalpIsHvPresent() )
    goto LABEL_22;
  v0 = 0x2000;
  if( (unsigned __int8)HalpTimerDeepestIdleState > 1u )
    v0 = 24576;
  result = (ULONG_PTR *)HalpFindTimer(5, 3, v0, 0, 0);
  if( !result )
  {
    result = (ULONG_PTR *)HalpFindTimer(10, 3, v0, 0, 0);
    if( !result )
    {
LABEL_22:
      if( !byte_140C4A318 || qword_140C4A148 || (result = (ULONG_PTR *)HalpFindTimer(3, 2, 24576, 0, 0)) == 0i64 )
      {
        result = (ULONG_PTR *)HalpFindTimer(8, 2, 0, 0, 0);
        if( !result )
        {
LABEL_9:
          result = (ULONG_PTR *)HalpFindTimer(11, 2, 24576, 0, 0);
          if( !result )
          {
            result = (ULONG_PTR *)HalpFindTimer(3, 2, 24576, 0, 0);
            if( !result )
            {
              result = (ULONG_PTR *)HalpFindTimer(6, 2, 24576, 0, 0);
              if( !result )
              {
                result = (ULONG_PTR *)HalpFindTimer(1, 2, 24576, 0, 0);
                if( !result )
                {
                  if( HalpIsHvPresent() )
                    return 0i64;
                  result = (ULONG_PTR *)HalpFindTimer(0, 2, 24576, 0, 0);
                  if( !result )
                    return 0i64;
                }
              }
            }
          }
        }
      }
    }
  }
  return result;
}

Referenced by:

HalpTimerSelectRoles