IopLiveDumpGetExtraMergePages

CHAR __fastcall IopLiveDumpGetExtraMergePages(_QWORD *a1, INT64 a2, _QWORD *a3, _DWORD *a4, _QWORD *a5){
  unsigned __int64 v5; 
  unsigned __int64 v7; 
  unsigned __int64 v8; 
  __int64 v9; 
  int v10; 
  __int64 v11; 
  unsigned __int64 v12; 
  unsigned __int64 v13; 
  unsigned __int64 v14; 
  unsigned __int64 v15; 
  CHAR v16; 
  unsigned __int64 v17; 
  int v18; 
  unsigned __int64 v19; 
  int v20; 
  bool v21; 
  signed __int64 *v22; 
  __int64 v24; 
  __int64 v25; 
  __int64 v26; 
  v5 = a1[30];
  if( __PAIR128__(a1[34], v5) == *((_OWORD *)a1 + 12) )
  {
LABEL_33:
    *a4 = 0;
    return 0;
  }
  v7 = a1[28];
  v8 = a1[24] - v5;
  v9 = a1[27];
  v10 = 0;
  v11 = 0i64;
  v12 = a1[25] - a1[34];
  v13 = v7 % (unsigned int)BufferChunkSizeInBytes;
  v14 = a1[32] % (unsigned __int64)(unsigned int)BufferChunkSizeInBytes;
  v25 = v9 + v7 / (unsigned int)BufferChunkSizeInBytes;
  v26 = v9 + a1[32] / (unsigned __int64)(unsigned int)BufferChunkSizeInBytes;
  v15 = (unsigned int)BufferChunkSizeInBytes;
  if( ((unsigned int)BufferChunkSizeInBytes - v13) >> 12 <= v8 )
    v8 = ((unsigned int)BufferChunkSizeInBytes - v13) >> 12;
  if( ((unsigned int)BufferChunkSizeInBytes - v14) >> 12 <= v12 )
    v12 = ((unsigned int)BufferChunkSizeInBytes - v14) >> 12;
  v16 = 1;
  while( 1 )
  {
    v17 = 0i64;
    if( v8 )
    {
      v18 = 1;
      v17 = *(_QWORD *)((a1[29] + 8 * v11) % v15 + *(_QWORD *)(a1[94] + 8 * ((a1[29] + 8 * v11) / v15 + a1[27]))) >> 12;
    }
    else
    {
      v18 = 0;
    }
    v19 = 0i64;
    if( v12 )
    {
      v20 = 1;
      v19 = *(_QWORD *)((a1[33] + 8 * (unsigned __int64)(unsigned int)v11) % v15
                      + *(_QWORD *)(a1[94] + 8 * ((a1[33] + 8 * (unsigned __int64)(unsigned int)v11) / v15 + a1[27]))) >> 12;
    }
    else
    {
      v20 = 0;
    }
    if( v10 )
      break;
    if( !v18 )
    {
      if( !v20 )
        goto LABEL_32;
      v10 = 1;
      break;
    }
    if( v20 )
    {
      v10 = 2 - (v19 < v17);
      break;
    }
    v10 = 2;
LABEL_18:
    if( !v18 )
      goto LABEL_32;
    if( !v20 )
      goto LABEL_22;
    v21 = v19 < v17;
LABEL_21:
    if( v21 )
      goto LABEL_32;
LABEL_22:
    if( v10 == 1 )
    {
      *(_QWORD *)(a2 + 8i64 * (unsigned int)v11) = v19;
      --v12;
      v22 = (signed __int64 *)a1[80];
    }
    else
    {
      *(_QWORD *)(a2 + 8i64 * (unsigned int)v11) = v17;
      --v8;
      v22 = (signed __int64 *)a1[78];
      v19 = v17;
    }
    _bittestandset64(v22, v19);
    v11 = (unsigned int)(v11 + 1);
  }
  if( v10 != 1 )
    goto LABEL_18;
  if( v20 )
  {
    if( !v18 )
      goto LABEL_22;
    v21 = v17 < v19;
    goto LABEL_21;
  }
LABEL_32:
  if( !(_DWORD)v11 )
    goto LABEL_33;
  v24 = a1[94];
  if( v10 == 1 )
  {
    *a5 = v26;
    *a3 = *(_QWORD *)(v24 + 8 * v26) + v14;
    if( v12 || a1[35] == v26 )
      v16 = 0;
    a1[34] += (unsigned int)v11;
    a1[32] += (unsigned int)((_DWORD)v11 << 12);
    a1[33] += 8i64 * (unsigned int)v11;
  }
  else
  {
    *a5 = v25;
    *a3 = *(_QWORD *)(v24 + 8 * v25) + v13;
    if( v8 || a1[31] == v25 )
      v16 = 0;
    a1[30] += (unsigned int)v11;
    a1[28] += (unsigned int)((_DWORD)v11 << 12);
    a1[29] += 8i64 * (unsigned int)v11;
  }
  *a4 = v11;
  return v16;
}

Referenced by:

IopLiveDumpWriteDumpFileWithExtraPages