WheapSortBadPages

void __fastcall WheapSortBadPages(__int64 a1, unsigned int a2){
  unsigned int v2; 
  unsigned int v4; 
  char v5; 
  __int64 v6; 
  unsigned __int64 *v7; 
  unsigned __int64 v8; 
  if( a2 >= 2 )
  {
    v2 = 0;
    v4 = a2 - 1;
    if( v4 )
    {
      do
      {
        v5 = 0;
        LODWORD(v6) = v4;
        if( v4 <= v2 )
          break;
        v7 = (unsigned __int64 *)(a1 + 8i64 * v4);
        do
        {
          v6 = (unsigned int)(v6 - 1);
          v8 = *(_QWORD *)(a1 + 8 * v6);
          if( v8 > *v7 )
          {
            *(_QWORD *)(a1 + 8 * v6) = *v7;
            v5 = 1;
            *v7 = v8;
          }
          --v7;
        }
        while( (unsigned int)v6 > v2 );
        if( !v5 )
          break;
        ++v2;
      }
      while( v2 < v4 );
    }
  }
}

Referenced by:

WheaPersistBadPageToBcd