RtlFindSetBitsAndClear
NTSTATUS __fastcall RtlFindSetBitsAndClear(INT64 a1, UINT64 a2, UINT64 a3){
unsigned int v3;
int v4;
UINT32 v5;
_RTL_BITMAP *v6;
int v7;
int v8;
unsigned int v9;
__int64 v10;
int v11;
unsigned int v12;
unsigned int v13;
__int64 v14;
unsigned int v15;
unsigned int v16;
__int64 v17;
unsigned __int64 v18;
_QWORD *v19;
signed __int64 v20;
unsigned __int64 v21;
int v22;
__int64 v23;
bool v24;
__int64 v25;
char v26;
_QWORD *v27;
unsigned int v28;
__int64 v29;
unsigned int v30;
int v31;
_QWORD *v32;
__int64 v33;
unsigned int v34;
unsigned __int64 v35;
__int64 v36;
int v37;
unsigned int v38;
__int64 v39;
__int64 v40;
bool v41;
unsigned __int64 v42;
int v44;
__int64 v45;
int v47;
int v48;
v47 = a3;
v3 = *(_DWORD *)a1;
v4 = a3;
v5 = a2;
v6 = (_RTL_BITMAP *)a1;
v7 = (unsigned int)a3 < *(_DWORD *)a1 ? a3 : 0;
v8 = *(_DWORD *)a1 - 1;
if( !(_DWORD)a2 )
{
v9 = v7 & 0xFFFFFFF8;
goto LABEL_79;
}
v10 = *(_QWORD *)(a1 + 8);
v45 = v10;
v11 = (v10 & 4) != 0 ? 0x20 : 0;
while( 1 )
{
v12 = v11 + v8;
v13 = v11 + v7;
v14 = v10 - ((v45 & 4) != 0 ? 4 : 0);
if( v8 - v7 + 1 < v5 )
{
v15 = -1;
goto LABEL_29;
}
v16 = v12 - v5 + 1;
v17 = (1i64 << (v13 & 0x3F)) - 1;
v18 = v14 + 8 * ((unsigned __int64)v16 >> 6);
v19 = (_QWORD *)(v14 + 8 * ((unsigned __int64)v13 >> 6));
v20 = ~*v19 | v17;
if( v5 > 0x7F )
{
v21 = v18 + 8;
if( (v16 & 0x3F) == 0 )
v21 = v14 + 8 * ((unsigned __int64)(v12 - v5 + 1) >> 6);
if( v20 )
{
v23 = ~*++v19;
if( *v19 != -1i64 )
goto LABEL_15;
v48 &= v23;
v24 = !_BitScanReverse64((unsigned __int64 *)&v23, v20);
if( v24 )
LABEL_13:
v22 = 64;
else
v22 = 63 - v23;
}
else
{
v22 = 0;
}
LABEL_19:
v15 = ((unsigned int)(((__int64)v19 - v14) >> 3) << 6) - v22;
if( v15 <= v16 )
{
v26 = v5 - v22;
v27 = &v19[(unsigned __int64)(v5 - v22) >> 6];
while( ++v19 != v27 )
{
if( *v19 != -1i64 )
goto LABEL_15;
}
v28 = v26 & 0x3F;
if( !v28 )
goto LABEL_27;
v24 = !_BitScanForward64((unsigned __int64 *)&v29, ~*v19);
if( v24 )
LODWORD(v29) = 64;
if( (unsigned int)v29 >= v28 )
goto LABEL_27;
LABEL_15:
while( (unsigned __int64)v19 <= v21 )
{
if( *++v19 == -1i64 )
{
v44 &= ~*(_DWORD *)v19;
v24 = !_BitScanReverse64((unsigned __int64 *)&v25, ~*(v19 - 1));
if( v24 )
goto LABEL_13;
v22 = 63 - v25;
goto LABEL_19;
}
}
}
goto LABEL_68;
}
if( v5 >= 0x40 )
{
while( 1 )
{
while( 1 )
{
while( v20 < 0 )
{
if( (unsigned __int64)++v19 > v18 )
goto LABEL_68;
v20 = ~*v19;
}
v24 = !_BitScanReverse64((unsigned __int64 *)&v36, v20);
if( v24 )
v37 = 64;
else
v37 = 63 - v36;
v15 = (((unsigned int)(((__int64)v19 - v14) >> 3) + 1) << 6) - v37;
if( v15 > v16 )
goto LABEL_68;
v38 = v5 - v37;
if( v5 == v37 )
goto LABEL_27;
v20 = ~*++v19;
if( v38 >= 0x40 )
break;
LABEL_59:
v24 = !_BitScanForward64((unsigned __int64 *)&v39, v20);
if( v24 )
LODWORD(v39) = 64;
if( (unsigned int)v39 >= v38 )
goto LABEL_27;
}
if( *v19 == -1i64 )
{
v38 -= 64;
if( !v38 )
goto LABEL_27;
v20 = ~*++v19;
goto LABEL_59;
}
}
}
if( v5 <= 1 )
{
while( v20 == -1 )
{
if( (unsigned __int64)++v19 > v18 )
goto LABEL_68;
v20 = ~*v19;
}
_BitScanForward64(&v42, ~v20);
v15 = v42 + ((unsigned int)(((__int64)v19 - v14) >> 3) << 6);
v41 = v15 <= v16;
LABEL_71:
if( v41 )
{
LABEL_27:
if( v15 != -1 )
break;
goto LABEL_28;
}
}
else
{
v31 = 0;
v32 = (_QWORD *)(v14 + 8 * ((unsigned __int64)v12 >> 6));
while( v20 != -1 )
{
LABEL_40:
v24 = !_BitScanForward64((unsigned __int64 *)&v33, v20);
if( v24 )
LODWORD(v33) = 64;
if( v31 + (int)v33 >= v5 )
{
LODWORD(v35) = -v31;
LABEL_70:
v15 = ((unsigned int)(((__int64)v19 - v14) >> 3) << 6) + v35;
v41 = v15 <= v16;
goto LABEL_71;
}
v34 = v5;
v35 = ~v20;
while( 1 )
{
v35 &= v35 >> (v34 >> 1);
if( !v35 )
break;
v34 -= v34 >> 1;
if( v34 <= 1 )
{
_BitScanForward64(&v35, v35);
goto LABEL_70;
}
}
if( v19 == v32 )
goto LABEL_68;
v24 = !_BitScanReverse64((unsigned __int64 *)&v40, v20);
if( v24 )
v31 = 64;
else
v31 = 63 - v40;
v20 = ~*++v19;
}
while( (unsigned __int64)++v19 <= v18 )
{
v20 = ~*v19;
if( *v19 )
{
v31 = 0;
goto LABEL_40;
}
}
}
LABEL_68:
v15 = -1;
LABEL_28:
v4 = v47;
LABEL_29:
if( !v7 )
break;
v10 = v45;
v30 = v5 + v4;
if( v5 + v4 > v3 )
v30 = v3;
v8 = v30 - 1;
v7 = 0;
}
v6 = (_RTL_BITMAP *)a1;
v9 = v15 - v11;
if( v15 == -1 )
v9 = -1;
LABEL_79:
if( v9 != -1 )
RtlClearBits(v6, v9, v5);
return v9;
}Referenced by:
No references.