RtlLengthCurrentClearRunForwardEx

INT64 __fastcall RtlLengthCurrentClearRunForwardEx(_QWORD *a1, UINT64 a2){
  __int64 v2; 
  unsigned int *v3; 
  __int64 v4; 
  unsigned __int64 v5; 
  unsigned __int64 v6; 
  __int64 v7; 
  UINT64 v8; 
  unsigned __int64 v9; 
  bool v10; 
  __int64 v11; 
  char v12; 
  __int64 v13; 
  char v15; 
  v2 = a1[1];
  v3 = (unsigned int *)(v2 + 4 * (a2 >> 5));
  v4 = *a1 & 0x1Fi64;
  v5 = (unsigned __int64)(*a1 - 1i64) >> 5;
  v6 = v2 + 4 * v5 - 4;
  if( !v4 )
    v6 = v2 + 4 * v5;
  v7 = 0i64;
  v8 = a2 & 0x1F;
  v9 = ~*((_DWORD *)qword_140011CE0 + v8) & *v3;
  if( (unsigned __int64)v3 > v6 )
  {
LABEL_14:
    if( !v4 )
      return v7 - v8;
    if( v7 )
      LODWORD(v9) = v3[1];
    v15 = -1;
    v10 = !_BitScanForward64(&v9, (unsigned int)v9 | ~*((_DWORD *)qword_140011CE0 + v4));
    if( !v10 )
      v15 = v9;
    v13 = (unsigned int)v15;
    goto LABEL_12;
  }
  if( (_DWORD)v9 )
  {
LABEL_9:
    v10 = !_BitScanForward64((unsigned __int64 *)&v11, v9);
    v12 = -1;
    if( !v10 )
      v12 = v11;
    v13 = (unsigned int)v12;
LABEL_12:
    v7 += v13;
    return v7 - v8;
  }
  while( 1 )
  {
    v7 += 32i64;
    if( v7 == -1 && v8 == 0 )
      return v7 - v8;
    if( v3 == (unsigned int *)v6 )
      goto LABEL_14;
    v9 = *++v3;
    if( (_DWORD)v9 )
      goto LABEL_9;
  }
}

Referenced by:

RtlCSparseBitmapFindBitSetCapped