RtlpFcQueryFeatureConfigurationFromBuffers

NTSTATUS __stdcall RtlpFcQueryFeatureConfigurationFromBuffers(INT64 a1, INT64 a2, INT64 a3, INT64 a4){
  _DWORD *v4; 
  NTSTATUS v5; 
  _DWORD *v8; 
  unsigned __int64 v9; 
  __int64 v10; 
  _DWORD *v11; 
  unsigned int v12; 
  unsigned __int64 v13; 
  _DWORD *v14; 
  int v15; 
  int v17; 

  v17 = a1;
  v4 = *(_DWORD **)(a2 + 8);
  v5 = 0;
  v8 = 0i64;
  if( !v4 )
    goto LABEL_9;
  v9 = (unsigned __int64)(v4 + 1);
  if( *v4 )
  {
    v8 = (_DWORD *)RtlpFcLowerBounds(
                     (__int64)&v17,
                     v9,
                     (unsigned int)*v4,
                     12i64,
                     (int(__fastcall *)(__int64, unsigned __int64))RtlFcpCompareFeatureIdToFeature);
    LODWORD(a1) = v17;
    if( v8 == &v4[3 * *v4 + 1] || *v8 != v17 )
      v8 = 0i64;
  }
  else
  {
    v10 = RtlpFcLinearSearchInSortedArray(
            (__int64)&v17,
            v9,
            0i64,
            12i64,
            (__int64(__fastcall *)(__int64, __int64))RtlFcpCompareFeatureIdToFeature);
    LODWORD(a1) = v17;
    v8 = (_DWORD *)v10;
  }
  if( v8 )
  {
    *(_QWORD *)a4 = *(_QWORD *)v8;
    *(_DWORD *)(a4 + 8) = v8[2];
  }
  else
  {
LABEL_9:
    *(_QWORD *)(a4 + 4) = 0i64;
    *(_DWORD *)a4 = a1;
  }
  v11 = *(_DWORD **)(a3 + 8);
  if( v11 )
  {
    v13 = (unsigned __int64)(v11 + 1);
    if( *v11 )
    {
      v14 = (_DWORD *)RtlpFcLowerBounds(
                        (__int64)&v17,
                        v13,
                        (unsigned int)*v11,
                        16i64,
                        (int(__fastcall *)(__int64, unsigned __int64))RtlFcpCompareFeatureIdToFeature);
      if( v14 == &v11[4 * *v11 + 1] || *v14 != v17 )
        v14 = 0i64;
    }
    else
    {
      v14 = (_DWORD *)RtlpFcLinearSearchInSortedArray(
                        (__int64)&v17,
                        v13,
                        0i64,
                        16i64,
                        (__int64(__fastcall *)(__int64, __int64))RtlFcpCompareFeatureIdToFeature);
    }
    v15 = *(_DWORD *)(a4 + 4);
    if( v14 )
      v12 = v15 | 0x80;
    else
      v12 = v15 & 0xFFFFFF7F;
    *(_DWORD *)(a4 + 4) = v12;
  }
  else
  {
    *(_DWORD *)(a4 + 4) &= ~0x80u;
    v12 = *(_DWORD *)(a4 + 4);
  }
  if( !v8 )
    return(v12 & 0x80u) != 0 ? 279 : -1073741275;
  return v5;
}

Referenced by:

RtlpFcQueryFeatureConfigurationFromBufferSet
wil_details_PopulateInitialConfiguredFeatureStatesFromBuffers