wil_details_GetCurrentFeatureEnabledState

wil_details_FeatureStateCache __stdcall wil_details_GetCurrentFeatureEnabledState(
        wil_details_FeatureDescriptor *a1,
        INT64 *a2){
  unsigned int featureId; 
  unsigned __int8 v3; 
  int v5; 
  _BOOL8 v6; 
  int v7; 
  int v8; 
  int v9; 
  int v10; 
  int FeatureState; 
  int v12; 
  int v13; 
  int v14; 
  unsigned int v15; 
  unsigned int v16; 
  const PUSER_THREAD_START_ROUTINE **requiresFeatures; 
  const PUSER_THREAD_START_ROUTINE *v18; 
  char CachedFeatureEnabledState; 
  bool v20; 
  int v21; 
  INT64 v23[2]; 
  __int64 v24; 
  wil_details_FeatureStateCache v25; 

  featureId = a1->featureId;
  v3 = a1->changeTime - 2;
  *(_OWORD *)v23 = 0i64;
  v5 = 1;
  *(_DWORD *)a2 = 1;
  v6 = v3 <= 1u;
  v24 = 0i64;
  v7 = RtlQueryFeatureConfiguration(featureId, v3 > 1u, &v25);
  if( v7 )
  {
    if( v7 == 279 )
      LODWORD(v24) = 0;
    FeatureState = wil_StagingConfig_QueryFeatureState(0, (INT64)v23, featureId, v6, 0i64);
    v9 = HIDWORD(v24);
    v5 = FeatureState;
    v10 = v24;
    v8 = v23[0];
  }
  else
  {
    v8 = 0;
    v9 = 0;
    v10 = 0;
  }
  v25.exchange64 = 0i64;
  v12 = (v10 != 0 ? 0x100 : 0) | (v9 != 0 ? 0x200 : 0);
  v13 = -v5;
  if( (((unsigned __int8)v12 | (unsigned __int8)(32 * ((v13 != 0 ? v8 : 0) & 3))) & 0x60) != 0 )
  {
    v14 = 0;
    if( v8 == 2 )
      v14 = 16;
  }
  else
  {
    v14 = a1->isEnabledByDefault != 0 ? 0x10 : 0;
  }
  v15 = v14 | v12 | (32 * ((unsigned __int8)v8 & (unsigned __int8)-(v13 != 0) & 3));
  v16 = v15 | (v15 >> 1) & 8;
  v25.exchange = v16;
  if( v15 & 8 | (v15 >> 1) & 8 )
  {
    requiresFeatures = (const PUSER_THREAD_START_ROUTINE **)a1->requiresFeatures;
    if( requiresFeatures )
    {
      do
      {
        v18 = *requiresFeatures;
        if( !*requiresFeatures )
          break;
        if( *((_BYTE *)v18 + 22) || *((_BYTE *)v18 + 21) )
        {
          if( (v16 & 8) == 0 )
            goto LABEL_21;
          v20 = *((_BYTE *)v18 + 23) == 0;
        }
        else
        {
          CachedFeatureEnabledState = wil_details_FeatureStateCache_GetCachedFeatureEnabledState(
                                        *(INT32 **)v18,
                                        *requiresFeatures);
          if( (v16 & 8) == 0 )
            goto LABEL_21;
          v20 = (CachedFeatureEnabledState & 8) == 0;
        }
        if( v20 )
        {
LABEL_21:
          v21 = 0;
          goto LABEL_22;
        }
        v21 = 8;
LABEL_22:
        ++requiresFeatures;
        v16 = v21 | v16 & 0xFFFFFFF7;
        v25.exchange = v16;
      }
      while( (v16 & 8) != 0 );
    }
  }
  return v25;
}

Referenced by:

wil_details_FeatureStateCache_ReevaluateCachedFeatureEnabledState