MiConfigureMemoryRemoval

__int64 __fastcall MiConfigureMemoryRemoval(_QWORD *a1, unsigned int *a2, _QWORD *a3){
  __int64 v3; 
  char v4; 
  unsigned int *v7; 
  unsigned int *v8; 
  unsigned __int64 v9; 
  __int64 v10; 
  unsigned __int64 v11; 
  int v12; 
  unsigned __int64 v13; 
  unsigned __int64 v14; 
  __int64 v15; 
  __int64 v17; 
  unsigned int v18; 
  unsigned int *v19; 
  __int64 v20; 
  _QWORD *v21; 
  unsigned __int64 v22; 
  unsigned __int64 v23; 
  __int64 v24; 
  __int64 v25; 
  v3 = *a2;
  v4 = 0;
  *a1 = 0i64;
  if( *a3 )
    v7 = &a2[4 * v3 + 4];
  else
    v7 = 0i64;
  v8 = a2 + 6;
  v9 = a3[2];
  v10 = 0i64;
  v25 = a3[3];
  v11 = v25 + v9;
  v12 = -2;
  while( 1 )
  {
    v13 = *((_QWORD *)v8 - 1);
    v14 = v13 + *(_QWORD *)v8;
    if( v9 >= v13 && v11 <= v14 )
      break;
    ++v10;
    v8 += 4;
    if( v10 == v3 )
      goto LABEL_15;
  }
  if( v9 != v13 )
  {
    if( v11 != v14 )
    {
      v12 = 1;
      goto LABEL_15;
    }
LABEL_14:
    v12 = 0;
    goto LABEL_15;
  }
  if( v11 != v14 )
    goto LABEL_14;
  v12 = -1;
LABEL_15:
  LODWORD(v15) = MiAllocatePool((struct _SLIST_ENTRY *)0x40);
  if( !v15 )
    return 3221225626i64;
  *(_QWORD *)(v15 + 8) = 1i64;
  *(_QWORD *)v15 = &MiSystemPartition;
  v17 = v15 + 32;
  v18 = v12 + *a2;
  v19 = a2 + 4;
  v20 = 0i64;
  *(_DWORD *)(v15 + 16) = v18;
  v21 = (_QWORD *)(v15 + 16 + 16 * (v18 + 1i64));
  *(_QWORD *)(v15 + 24) = *((_QWORD *)a2 + 1) - v25;
  do
  {
    v22 = *(_QWORD *)v19;
    v23 = *(_QWORD *)v19 + *((_QWORD *)v19 + 1);
    if( (v4 & 1) != 0 || v9 < v22 || v11 > v23 )
    {
      *(_OWORD *)v17 = *(_OWORD *)v19;
      goto LABEL_31;
    }
    v4 |= 1u;
    if( v9 == v22 )
    {
      if( v11 == v23 )
        goto LABEL_33;
      v22 += v25;
LABEL_24:
      *(_QWORD *)v17 = v22;
      *(_QWORD *)(v17 + 8) = *((_QWORD *)v19 + 1) - v25;
LABEL_31:
      v17 += 16i64;
      if( v7 )
        *v21++ = *(_QWORD *)&v7[2 * v20];
      goto LABEL_33;
    }
    if( v11 == v23 )
      goto LABEL_24;
    *(_QWORD *)v17 = v22;
    *(_QWORD *)(v17 + 8) = v9 - v22;
    if( v7 )
    {
      v24 = 2i64;
      do
      {
        *v21++ = *(_QWORD *)&v7[2 * v20];
        --v24;
      }
      while( v24 );
    }
    *(_QWORD *)(v17 + 16) = v11;
    *(_QWORD *)(v17 + 24) = v23 - v11;
    v17 += 32i64;
LABEL_33:
    ++v20;
    v19 += 4;
  }
  while( v20 != *a2 );
  *a1 = v15 + 16;
  return 0i64;
}

Referenced by:

MiRemovePhysicalMemory