IopAddRemoveReqDescs

VOID __stdcall IopAddRemoveReqDescs(
        _REQ_DESC **ReqDescTable,
        UINT64 ReqDescCount,
        _LIST_ENTRY *ActiveArbiterList,
        UINT8 Add){
  __int64 v4; 
  unsigned int v7; 
  _REQ_DESC *v9; 
  __int64 v10; 
  char v11; 
  _QWORD *v12; 
  _QWORD *v13; 
  _LIST_ENTRY *v14; 
  _LIST_ENTRY *i; 
  __int64 v16; 
  _QWORD *v17; 
  _QWORD *v18; 
  __int64 v19; 
  _QWORD *v20; 
  __int64 v21; 

  if( (_DWORD)ReqDescCount )
  {
    v4 = 0i64;
    v7 = ReqDescCount;
    do
    {
      v9 = ReqDescTable[v4];
      if( *((_BYTE *)v9 + 8) )
      {
        v10 = *((_QWORD *)v9 + 36);
        v11 = *(_BYTE *)(v10 + 104);
        if( (v11 & 1) != 0 )
        {
          v21 = *(_QWORD *)(v10 + 24);
          *(_BYTE *)(v10 + 104) = v11 & 0xFE;
          (*(void(__fastcall **)(_QWORD, __int64))(v21 + 32))(*(_QWORD *)(v21 + 8), 3i64);
        }
        *(_BYTE *)(v10 + 105) = 1;
        v12 = (_QWORD *)(*((_QWORD *)v9 + 4) + 40i64);
        if( Add )
        {
          *(_QWORD *)(*((_QWORD *)v9 + 4) + 48i64) = *((_QWORD *)v9 + 4) + 40i64;
          *v12 = v12;
          v13 = *(_QWORD **)(v10 + 48);
          if( *v13 != v10 + 40 )
            goto LABEL_20;
          v12[1] = v13;
          *v12 = v10 + 40;
          *v13 = v12;
          v14 = (_LIST_ENTRY *)(v10 + 88);
          *(_QWORD *)(v10 + 48) = v12;
          if( v14->Flink == v14 )
          {
            for( i = ActiveArbiterList->Flink; i != ActiveArbiterList; i = i->Flink )
            {
              if( LODWORD(i[-4].Blink[9].Blink) >= *(_DWORD *)(*(_QWORD *)(v10 + 32) + 152i64) )
                break;
            }
            v14->Flink = i;
            *(_QWORD *)(v10 + 96) = i->Blink;
            i->Blink->Flink = v14;
            i->Blink = v14;
          }
        }
        else
        {
          v16 = *v12;
          if( *(_QWORD **)(*v12 + 8i64) != v12
            || (v17 = *(_QWORD **)(*((_QWORD *)v9 + 4) + 48i64), (_QWORD *)*v17 != v12) )
          {
LABEL_20:
            __fastfail(3u);
          }
          *v17 = v16;
          *(_QWORD *)(v16 + 8) = v17;
          v12[1] = v12;
          *v12 = v12;
          if( *(_QWORD *)(v10 + 40) == v10 + 40 )
          {
            v18 = (_QWORD *)(v10 + 88);
            v19 = *(_QWORD *)(v10 + 88);
            if( *(_QWORD *)(v19 + 8) != v10 + 88 )
              goto LABEL_20;
            v20 = *(_QWORD **)(v10 + 96);
            if( (_QWORD *)*v20 != v18 )
              goto LABEL_20;
            *v20 = v19;
            *(_QWORD *)(v19 + 8) = v20;
            *(_QWORD *)(v10 + 96) = v10 + 88;
            *v18 = v18;
          }
        }
      }
      v4 = (unsigned int)(v4 + 1);
    }
    while( (unsigned int)v4 < v7 );
  }
}

Referenced by:

IopBootAllocation
IopSelectNextConfiguration
PnpFindBestConfigurationWorker
PnpSelectFirstConfiguration