RtlFindSetBits
NTSTATUS __fastcall RtlFindSetBits(INT64 a1, UINT64 a2, UINT64 a3){
unsigned int v3;
int v4;
unsigned int v5;
int v6;
int v7;
__int64 v8;
__int64 v9;
int v10;
unsigned int v11;
unsigned int v12;
__int64 v13;
unsigned int v14;
__int64 v15;
unsigned __int64 v16;
_QWORD *v17;
signed __int64 v18;
unsigned __int64 v19;
unsigned int v20;
bool v21;
NTSTATUS v22;
unsigned int v24;
int v25;
_QWORD *v26;
bool v27;
__int64 v28;
unsigned int v29;
unsigned __int64 v30;
__int64 v31;
int v32;
unsigned int v33;
__int64 v34;
unsigned __int64 v35;
int v36;
char v37;
_QWORD *v38;
__int64 v39;
unsigned int v40;
__int64 v41;
__int64 v42;
__int64 v43;
__int64 v44;
__int64 v45;
int v46;
v3 = *(_DWORD *)a1;
v4 = a3;
v5 = a2;
v6 = (unsigned int)a3 < *(_DWORD *)a1 ? a3 : 0;
v7 = *(_DWORD *)a1 - 1;
if( !(_DWORD)a2 )
return v6 & 0xFFFFFFF8;
v8 = *(_QWORD *)(a1 + 8);
v45 = v8;
v9 = v8 & 4;
v44 = v9;
v10 = v9 != 0 ? 0x20 : 0;
while( 1 )
{
v11 = v10 + v7;
v12 = v10 + v6;
v13 = v8 - (v9 != 0 ? 4 : 0);
if( v7 - v6 + 1 < v5 )
{
LABEL_16:
v20 = -1;
goto LABEL_17;
}
v14 = v11 - v5 + 1;
v15 = (1i64 << (v12 & 0x3F)) - 1;
v16 = v13 + 8 * ((unsigned __int64)v14 >> 6);
v17 = (_QWORD *)(v13 + 8 * ((unsigned __int64)v12 >> 6));
v18 = ~*v17 | v15;
if( v5 > 0x7F )
{
v35 = v16 + 8;
if( (v14 & 0x3F) == 0 )
v35 = v13 + 8 * ((unsigned __int64)(v11 - v5 + 1) >> 6);
if( !v18 )
{
v36 = 0;
goto LABEL_53;
}
if( *++v17 != -1i64 )
goto LABEL_59;
v27 = !_BitScanReverse64((unsigned __int64 *)&v43, v18);
if( !v27 )
{
v36 = 63 - v43;
goto LABEL_53;
}
LABEL_78:
v36 = 64;
LABEL_53:
while( 1 )
{
v20 = ((unsigned int)(((__int64)v17 - v13) >> 3) << 6) - v36;
if( v20 > v14 )
goto LABEL_16;
v37 = v5 - v36;
v38 = &v17[(unsigned __int64)(v5 - v36) >> 6];
while( ++v17 != v38 )
{
if( *v17 != -1i64 )
goto LABEL_59;
}
v40 = v37 & 0x3F;
if( !v40 )
goto LABEL_12;
v27 = !_BitScanForward64((unsigned __int64 *)&v41, ~*v17);
if( v27 )
LODWORD(v41) = 64;
if( (unsigned int)v41 >= v40 )
goto LABEL_12;
do
{
LABEL_59:
if( (unsigned __int64)v17 > v35 )
goto LABEL_16;
++v17;
}
while( *v17 != -1i64 );
v46 &= ~*(_DWORD *)v17;
v27 = !_BitScanReverse64((unsigned __int64 *)&v39, ~*(v17 - 1));
if( v27 )
goto LABEL_78;
v36 = 63 - v39;
}
}
if( v5 >= 0x40 )
{
while( 1 )
{
while( 1 )
{
while( v18 < 0 )
{
if( (unsigned __int64)++v17 > v16 )
goto LABEL_16;
v18 = ~*v17;
}
v27 = !_BitScanReverse64((unsigned __int64 *)&v31, v18);
if( v27 )
v32 = 64;
else
v32 = 63 - v31;
v20 = (((unsigned int)(((__int64)v17 - v13) >> 3) + 1) << 6) - v32;
if( v20 > v14 )
goto LABEL_16;
v33 = v5 - v32;
if( v5 == v32 )
goto LABEL_12;
v18 = ~*++v17;
if( v33 >= 0x40 )
break;
LABEL_45:
v27 = !_BitScanForward64((unsigned __int64 *)&v34, v18);
if( v27 )
LODWORD(v34) = 64;
if( (unsigned int)v34 >= v33 )
goto LABEL_12;
}
if( *v17 == -1i64 )
{
v33 -= 64;
if( !v33 )
goto LABEL_12;
v18 = ~*++v17;
goto LABEL_45;
}
}
}
if( v5 > 1 )
{
v25 = 0;
v26 = (_QWORD *)(v13 + 8 * ((unsigned __int64)v11 >> 6));
while( v18 != -1 )
{
LABEL_23:
v27 = !_BitScanForward64((unsigned __int64 *)&v28, v18);
if( v27 )
LODWORD(v28) = 64;
if( v25 + (int)v28 >= v5 )
{
LODWORD(v30) = -v25;
LABEL_30:
v20 = ((unsigned int)(((__int64)v17 - v13) >> 3) << 6) + v30;
v21 = v20 <= v14;
goto LABEL_11;
}
v29 = v5;
v30 = ~v18;
while( 1 )
{
v30 &= v30 >> (v29 >> 1);
if( !v30 )
break;
v29 -= v29 >> 1;
if( v29 <= 1 )
{
_BitScanForward64(&v30, v30);
goto LABEL_30;
}
}
if( v17 == v26 )
goto LABEL_16;
v27 = !_BitScanReverse64((unsigned __int64 *)&v42, v18);
if( v27 )
v25 = 64;
else
v25 = 63 - v42;
v18 = ~*++v17;
}
while( 1 )
{
if( (unsigned __int64)++v17 > v16 )
goto LABEL_16;
v18 = ~*v17;
if( *v17 )
{
v25 = 0;
goto LABEL_23;
}
}
}
while( v18 == -1 )
{
if( (unsigned __int64)++v17 > v16 )
goto LABEL_16;
v18 = ~*v17;
}
_BitScanForward64(&v19, ~v18);
v20 = v19 + ((unsigned int)(((__int64)v17 - v13) >> 3) << 6);
v21 = v20 <= v14;
LABEL_11:
if( !v21 )
goto LABEL_16;
LABEL_12:
if( v20 != -1 )
break;
LABEL_17:
if( !v6 )
break;
v9 = v44;
v24 = v5 + v4;
v8 = v45;
if( v5 + v4 > v3 )
v24 = v3;
v7 = v24 - 1;
v6 = 0;
}
v22 = v20 - v10;
if( v20 == -1 )
return -1;
return v22;
}Referenced by:
EtwQueryPerformanceTraceInformation
HvpFindFreeCell
HvpRemoveFreeCellHint
MiFindDriverNonPagedSections
SmcStorePlacementGet