RtlFindNextForwardRunClear

NTSTATUS __fastcall RtlFindNextForwardRunClear(INT64 a1, UINT64 a2, UINT64 *a3){
  unsigned int v3; 
  unsigned int v5; 
  __int64 v7; 
  _DWORD *v8; 
  _DWORD *v9; 
  NTSTATUS v10; 
  int v11; 
  unsigned int v12; 
  unsigned int i; 
  _DWORD *v16; 

  v3 = *(_DWORD *)a1;
  v5 = a2;
  if( *(_DWORD *)a1 <= (unsigned int)a2 )
  {
    *(_DWORD *)a3 = a2;
    return 0;
  }
  v7 = *(_QWORD *)(a1 + 8);
  v8 = (_DWORD *)(v7 + 4 * ((unsigned __int64)(v3 - 1) >> 5));
  v9 = (_DWORD *)(v7 + 4 * ((unsigned __int64)v5 >> 5));
  if( v9 != v8 && (*v9 | *((_DWORD *)qword_140011CE0 + (v5 & 0x1F))) == -1 )
  {
    v5 = v5 - (v5 & 0x1F) + 32;
    for( ++v9; v9 < v8 && *v9 == -1; ++v9 )
      v5 += 32;
  }
  for( ; v5 < v3; ++v5 )
  {
    if( !_bittest(*(const signed __int32 **)(a1 + 8), v5) )
      break;
  }
  v10 = 0;
  if( v9 == v8 )
    goto LABEL_13;
  v11 = v5 & 0x1F;
  if( (*v9 & ~*((_DWORD *)qword_140011CE0 + (v5 & 0x1F))) != 0 )
    goto LABEL_13;
  v10 = 32 - v11;
  if( v11 != 33 )
  {
    v16 = v9 + 1;
    while( v16 < v8 && !*v16 )
    {
      ++v16;
      v10 += 32;
      if( v10 == -1 )
        goto LABEL_17;
    }
LABEL_13:
    v12 = *(_DWORD *)a1;
    for( i = v10 + v5; i < v12; ++v10 )
    {
      if( _bittest(*(const signed __int32 **)(a1 + 8), i) )
        break;
      if( v10 == -1 )
        break;
      ++i;
    }
  }
LABEL_17:
  *(_DWORD *)a3 = v5;
  return v10;
}

Referenced by:

HalpIrtAllocateIndex
HvpCountSetRangesInVector
HvpGenerateLogMetadata
MiFindDriverNonPagedSections
MiPrepareToHotPatchImage
PnprMirrorMarkedPages
PopGetRemainingHibernateRangeDataSize
ViThunkSnapSharedExports