PopIdleWakeInsertTimeInterval

INT64 __fastcall PopIdleWakeInsertTimeInterval(UINT64 a1, UINT64 a2, INT64 a3, INT64 a4, UINT64 *a5){
  __int64 v5; 
  UINT64 *i; 
  INT64 result; 
  if( (_DWORD)a2 )
  {
    v5 = 0i64;
    for( i = a5; ; ++i )
    {
      if( a1 >= *i )
      {
        result = (unsigned int)(v5 + 1);
        if( a1 < a5[result] )
          break;
      }
      v5 = (unsigned int)(v5 + 1);
      if( (unsigned int)v5 >= (unsigned int)a2 )
        return result;
    }
    ++*(_DWORD *)(a3 + 4 * v5);
    if( a4 )
      *(_QWORD *)(a4 + 8 * v5) += a1;
  }
  return result;
}

Referenced by:

PopIdleWakeNotifyIdleResiliencyState
PopIdleWakeStopActiveIntervalAccounting