MiCompressImportList

_LOAD_IMPORTS *__stdcall MiCompressImportList(_LOAD_IMPORTS *ImportList){
  unsigned __int64 v1; 
  __int64 v2; 
  unsigned int v3; 
  INT64 v4; 
  __int64 v6; 
  __int64 v7; 
  _LOAD_IMPORTS **v8; 
  __int64 v9; 
  __int64 v10; 
  unsigned __int64 v11; 
  __int64 v12; 
  unsigned int v13; 
  __int64 v14; 
  __int64 v15; 

  v1 = *(_QWORD *)ImportList;
  v2 = 0i64;
  v3 = 0;
  LODWORD(v4) = 0;
  if( !*(_QWORD *)ImportList )
    goto LABEL_18;
  v6 = 0i64;
  do
  {
    v7 = *(_QWORD *)&ImportList[2 * v6 + 2];
    v8 = (_LOAD_IMPORTS **)v3;
    v9 = v7 | 1;
    if( !v7 )
      v9 = v2;
    v2 = v9;
    v3 = (_DWORD)v8 + 1;
    if( !v7 )
      v3 = (unsigned int)v8;
    v4 = (unsigned int)(v4 + 1);
    v6 = (unsigned int)v4;
  }
  while( (unsigned int)v4 < v1 );
  if( !v3 )
  {
LABEL_18:
    v2 = -2i64;
    goto LABEL_17;
  }
  if( v3 == 1 )
  {
LABEL_17:
    ExFreePoolWithTag(ImportList, 0);
    return(_LOAD_IMPORTS *)v2;
  }
  if( v3 != v1 )
  {
    MiAllocateImportList((_IMAGE_IMPORT_DESCRIPTOR *)v3, v8, v1, v4);
    v2 = v10;
    if( v10 )
    {
      v11 = *(_QWORD *)ImportList;
      v12 = 0i64;
      v13 = 0;
      if( *(_QWORD *)ImportList )
      {
        v14 = 0i64;
        do
        {
          v15 = *(_QWORD *)&ImportList[2 * v14 + 2];
          if( v15 )
          {
            *(_QWORD *)(v2 + 8 * v12 + 8) = v15;
            v12 = (unsigned int)(v12 + 1);
          }
          v14 = ++v13;
        }
        while( v13 < v11 );
      }
      goto LABEL_17;
    }
  }
  return ImportList;
}

Referenced by:

MiAddEntryToImportList
MiResolveImageReferences