CmpDeleteTree

CHAR __fastcall CmpDeleteTree(UINT64 a1, UINT64 a2){
  int v2; 
  unsigned int v4; 
  _CM_KEY_NODE *v5; 
  unsigned int Parent; 
  int SubKeyByNumber; 
  __int64 v8; 
  int v9; 
  int v11; 
  int v12; 
  UINT ChildCell; 
  ChildCell = 0;
  v2 = a2;
  v11 = -1;
  v4 = a2;
  v12 = 0;
  while( 1 )
  {
    while( 1 )
    {
      v5 = (_CM_KEY_NODE *)(*(__int64(__fastcall **)(UINT64, _QWORD, int *))(a1 + 8))(a1, v4, &v11);
      if( !v5 )
        return 0;
      Parent = v5->Parent;
      if( !(v5->SubKeyCounts[0] + v5->SubKeyCounts[1]) )
        break;
      SubKeyByNumber = CmpFindSubKeyByNumber((_HHIVE *)a1, v5, 0i64, &ChildCell);
      (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, &v11);
      if( SubKeyByNumber < 0 )
        return 0;
      if( ChildCell == -1 )
        return 0;
      v8 = (*(__int64(__fastcall **)(UINT64, _QWORD, int *))(a1 + 8))(a1, ChildCell, &v11);
      if( !v8 )
        return 0;
      v9 = *(_DWORD *)(v8 + 20) + *(_DWORD *)(v8 + 24);
      (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, &v11);
      if( v9 )
      {
        v4 = ChildCell;
      }
      else if( CmpFreeKeyByCell((_HHIVE *)a1, ChildCell, 1u) < 0 )
      {
        return 0;
      }
    }
    (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, &v11);
    if( v4 == v2 )
      break;
    v4 = Parent;
  }
  return 1;
}

Referenced by:

CmRestoreKey
CmpSyncSubKeysAfterDelete