CmpDuplicateIndex

INT64 __fastcall CmpDuplicateIndex(UINT64 a1, INT64 a2, UINT64 a3){
  unsigned int v4; 
  __int64(__fastcall *v5)(UINT64, INT64, int *); 
  unsigned int v6; 
  unsigned int v7; 
  _DWORD *v8; 
  _WORD *v9; 
  _WORD *v10; 
  unsigned int v12; 
  UINT64 v13; 
  _DWORD *v14; 
  unsigned int v15; 
  int v16; 
  __int64 v17; 
  int v18; 
  int v19; 
  int v20; 
  int v21; 
  v19 = 0;
  v4 = a3;
  v21 = 0;
  v5 = *(__int64(__fastcall **)(UINT64, INT64, int *))(a1 + 8);
  v6 = 0;
  v18 = -1;
  v7 = a2;
  v20 = -1;
  v8 = 0i64;
  v9 = (_WORD *)v5(a1, a2, &v18);
  v10 = v9;
  if( !v9 )
    return 0xFFFFFFFFi64;
  if( *v9 == 26994 )
  {
    v12 = HvDuplicateCell(a1, v7, v4, 0);
    v13 = a1;
    if( v12 == -1 )
    {
LABEL_5:
      (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(v13, &v18);
      return 0xFFFFFFFFi64;
    }
    v14 = (_DWORD *)(*(__int64(__fastcall **)(UINT64, _QWORD, int *))(a1 + 8))(a1, v12, &v20);
    v8 = v14;
    if( !v14 )
    {
LABEL_14:
      HvFreeCell(a1, v12);
      v13 = a1;
      goto LABEL_5;
    }
    *v14 = 26994;
    v15 = 0;
    if( v10[1] )
    {
      while( 1 )
      {
        v16 = HvDuplicateCell(a1, *(unsigned int *)&v10[2 * v15 + 2], v4, 1);
        if( v16 == -1 )
          break;
        v17 = v15++;
        v8[v17 + 1] = v16;
        ++*((_WORD *)v8 + 1);
        if( v15 >= (unsigned __int16)v10[1] )
          goto LABEL_16;
      }
      if( *((_WORD *)v8 + 1) )
      {
        do
          HvFreeCell(a1, (unsigned int)v8[++v6]);
        while( v6 < *((unsigned __int16 *)v8 + 1) );
      }
      (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, &v20);
      goto LABEL_14;
    }
  }
  else
  {
    v12 = HvDuplicateCell(a1, v7, v4, 1);
  }
LABEL_16:
  if( v8 )
    (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, &v20);
  (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, &v18);
  return v12;
}

Referenced by:

CmRenameKey
CmpLightWeightDuplicateParentLists