MiMirrorReduceBlackToActiveAndPrivatePages

INT64 __fastcall MiMirrorReduceBlackToActiveAndPrivatePages(INT64 a1){
  unsigned __int64 v1; 
  unsigned __int64 v3; 
  unsigned __int64 v4; 
  INT64 result; 
  unsigned __int64 v6; 
  _QWORD *v7; 
  INT64 i; 
  __int64 v9; 
  unsigned __int64 v10; 
  unsigned __int64 v11; 
  unsigned __int64 v12; 
  _DWORD *v13; 
  unsigned __int64 v14; 
  _DWORD *v15; 
  unsigned __int64 j; 
  INT64 v17; 
  v1 = 0i64;
  do
  {
    v3 = v1 & -(__int64)(v1 < qword_140C4E460);
    v4 = qword_140C4E460 - 1;
    while( 1 )
    {
      result = v4 - v3 + 1;
      if( v4 - v3 == -1i64 )
        goto LABEL_4;
      v7 = (_QWORD *)(qword_140C4E468 + 8 * (v3 >> 6));
      result = ~*v7;
      for( i = result | ((1i64 << (v3 & 0x3F)) - 1); i == -1; i = ~*v7 )
      {
        if( (unsigned __int64)++v7 > qword_140C4E468 + 8 * (v4 >> 6) )
          goto LABEL_4;
      }
      _BitScanForward64((unsigned __int64 *)&result, ~i);
      v6 = result + (((__int64)v7 - qword_140C4E468) >> 3 << 6);
      if( v6 > v4 )
      {
LABEL_4:
        v6 = -1i64;
      }
      else if( v6 != -1i64 )
      {
        break;
      }
      if( !v3 )
        break;
      v9 = v1 + 1;
      if( v1 + 1 > qword_140C4E460 )
        v9 = qword_140C4E460;
      v4 = v9 - 1;
      v3 = 0i64;
    }
    if( v6 < v1 || v6 == -1i64 )
      break;
    if( qword_140C4E460 <= v6 )
    {
      v10 = 0i64;
LABEL_42:
      v11 = qword_140C4E460;
      goto LABEL_43;
    }
    v11 = v6;
    v12 = qword_140C4E468 + 4 * ((unsigned __int64)(qword_140C4E460 - 1) >> 5);
    v13 = (_DWORD *)(qword_140C4E468 + 4 * (v6 >> 5));
    if( v13 != (_DWORD *)v12 && (*v13 | *((_DWORD *)qword_140011CE0 + (v6 & 0x1F))) == -1 )
    {
      v11 = (v6 & 0xFFFFFFFFFFFFFFE0ui64) + 32;
      for( ++v13; (unsigned __int64)v13 < v12 && *v13 == -1; ++v13 )
        v11 += 32i64;
    }
    while( v11 < qword_140C4E460 && _bittest64((const signed __int64 *)qword_140C4E468, v11) )
      ++v11;
    v10 = 0i64;
    if( v13 != (_DWORD *)v12 )
    {
      v14 = v11 & 0x1F;
      if( (~*((_DWORD *)qword_140011CE0 + v14) & *v13) == 0 )
      {
        v10 = 32 - v14;
        if( v14 == 33 )
          goto LABEL_41;
        v15 = v13 + 1;
        while( (unsigned __int64)v15 < v12 && !*v15 )
        {
          ++v15;
          v10 += 32i64;
          if( v10 == -1i64 )
            goto LABEL_41;
        }
      }
    }
    for( j = v10 + v11; j < qword_140C4E460 && !_bittest64((const signed __int64 *)qword_140C4E468, j) && v10 != -1i64; ++j )
      ++v10;
LABEL_41:
    if( !v10 )
      goto LABEL_42;
LABEL_43:
    v17 = v11 - v6;
    result = MiMirrorRemoveInactivePages(a1, v6, v17);
    v1 = v17 + v10 + v6;
  }
  while( v1 < qword_140C4E460 );
  return result;
}

Referenced by:

MiMirrorBlackPhase