RtlpHeapFindListLookupEntry

_MMINPAGE_SUPPORT *__stdcall RtlpHeapFindListLookupEntry(_LIST_ENTRY *CoalescedList, UINT64 CoalescedSize){
  UINT8 v2; 
  int v3; 
  __int64 v4; 
  unsigned int v5; 
  _MMINPAGE_SUPPORT *v7; 
  int v8; 
  UINT8 v9; 
  _LIST_ENTRY *v11; 
  __int64 v12; 
  _MMINPAGE_SUPPORT *i; 
  __int64 v14; 
  unsigned int *v15; 
  unsigned int v16; 
  int v17; 
  unsigned int v18; 
  __int64 v19; 
  UINT64 Size; 

  v4 = *(_QWORD *)(CoalescedSize + 32);
  v5 = v3 - *(_DWORD *)(CoalescedSize + 24);
  v7 = 0i64;
  v8 = v3;
  v9 = v2;
  v11 = *(_LIST_ENTRY **)(v4 + 8);
  if( (_LIST_ENTRY *)v4 == v11 || RtlpHeapListCompare((_HEAP *)CoalescedList, v11, Size, v2) > 0 )
    return(_MMINPAGE_SUPPORT *)v4;
  if( RtlpHeapListCompare((_HEAP *)CoalescedList, *(_LIST_ENTRY **)v4, Size, v9) <= 0 )
    return *(_MMINPAGE_SUPPORT **)v4;
  if( *(_QWORD *)CoalescedSize || v8 != *(_DWORD *)(CoalescedSize + 8) - 1 )
  {
    v14 = v5 >> 5;
    v15 = (unsigned int *)(*(_QWORD *)(CoalescedSize + 40) + 4 * v14);
    v16 = *v15 & (-1 << (v5 & 0x1F));
    if( v16 )
      goto LABEL_20;
    do
    {
      if( (unsigned int)v14 > ((unsigned int)(*(_DWORD *)(CoalescedSize + 8) - *(_DWORD *)(CoalescedSize + 24)) >> 5)
                             - 1 )
        break;
      ++v15;
      LODWORD(v14) = v14 + 1;
      v16 = *v15;
    }
    while( !*v15 );
    if( v16 )
    {
LABEL_20:
      if( (_WORD)v16 )
      {
        if( (_BYTE)v16 )
          v17 = *((unsigned __int8 *)RtlpBitsClearLow + (unsigned __int8)v16);
        else
          v17 = *((unsigned __int8 *)RtlpBitsClearLow + BYTE1(v16)) + 8;
      }
      else if( (v16 & 0xFF0000) != 0 )
      {
        v17 = *((unsigned __int8 *)RtlpBitsClearLow + BYTE2(v16)) + 16;
      }
      else
      {
        v17 = *((unsigned __int8 *)RtlpBitsClearLow + ((unsigned __int64)v16 >> 24)) + 24;
      }
      v18 = 32 * v14 + v17;
      v19 = 2 * v18;
      if( !*(_DWORD *)(CoalescedSize + 12) )
        v19 = v18;
      return *(_MMINPAGE_SUPPORT **)(*(_QWORD *)(CoalescedSize + 48) + 8 * v19);
    }
  }
  else
  {
    v12 = 2 * v5;
    if( !*(_DWORD *)(CoalescedSize + 12) )
      v12 = v5;
    for( i = *(_MMINPAGE_SUPPORT **)(*(_QWORD *)(CoalescedSize + 48) + 8 * v12);
          (_MMINPAGE_SUPPORT *)v4 != i;
          i = *(_MMINPAGE_SUPPORT **)i->gap0 )
    {
      if( RtlpHeapListCompare((_HEAP *)CoalescedList, (_LIST_ENTRY *)i, Size, v9) <= 0 )
        return i;
    }
  }
  return v7;
}

Referenced by:

RtlpFindEntry
RtlpFindUCREntry