CmpKeyEnumStackAdvanceInternal

__int64 __fastcall CmpKeyEnumStackAdvanceInternal(__int64 a1){
  unsigned int v1; 
  INT16 v3; 
  _CM_KEY_NODE *v4; 
  INT16 v5; 
  INT64 v6; 
  _CM_KEY_NODE *v7; 
  INT16 i; 
  INT16 v10; 
  _QWORD *EntryAtLayerHeight; 
  __int64 *v12; 
  INT64 v13; 
  _CM_KEY_NODE *v14; 
  INT64 v15; 
  __int64 v16; 
  __int64 v17; 

  v1 = 0;
  if( *(_BYTE *)(a1 + 2) )
  {
    for( i = 0; i <= *(__int16 *)a1; ++i )
    {
      EntryAtLayerHeight = (_QWORD *)CmpKeyNodeStackGetEntryAtLayerHeight(a1 + 8, i);
      if( EntryAtLayerHeight[2] )
      {
        v12 = (__int64 *)CmpKeyEnumStackGetEntryAtLayerHeight(a1, v10);
        CmpKeyEnumStackEntryAdvance(v12);
        if( EntryAtLayerHeight[2] )
          (*(void(__fastcall **)(_QWORD, _QWORD *))(*EntryAtLayerHeight + 16i64))(
            *EntryAtLayerHeight,
            EntryAtLayerHeight + 3);
        *EntryAtLayerHeight = 0i64;
        *(_QWORD *)((char *)EntryAtLayerHeight + 12) = 0i64;
        *((_DWORD *)EntryAtLayerHeight + 5) = 0;
        *((_DWORD *)EntryAtLayerHeight + 2) = -1;
        EntryAtLayerHeight[3] = 0i64;
        *((_DWORD *)EntryAtLayerHeight + 6) = -1;
        *((_WORD *)EntryAtLayerHeight + 14) = 0;
      }
    }
  }
  v3 = *(_WORD *)a1;
  *(_BYTE *)(a1 + 2) = 1;
  v4 = 0i64;
  v5 = -1;
  if( v3 < 0 )
    return(unsigned int)-2147483622;
  do
  {
    v6 = CmpKeyEnumStackGetEntryAtLayerHeight(a1, v3);
    v7 = *(_CM_KEY_NODE **)(v6 + 120);
    if( v7 && (!v4 || (int)CmpCompareKeysByName(*(_CM_KEY_NODE **)(v6 + 120), v4) < 0) )
    {
      v4 = v7;
      v5 = v3;
    }
    --v3;
  }
  while( v3 >= 0 );
  if( v4 )
  {
    for( ; v5 >= 0; --v5 )
    {
      v13 = CmpKeyEnumStackGetEntryAtLayerHeight(a1, v5);
      v14 = *(_CM_KEY_NODE **)(v13 + 120);
      if( v14 && (v14 == v4 || !(unsigned int)CmpCompareKeysByName(v14, v4)) )
      {
        v15 = CmpKeyNodeStackGetEntryAtLayerHeight(a1 + 8, v5);
        v16 = *(_QWORD *)v13;
        v17 = *(unsigned int *)(v13 + 112);
        *(_QWORD *)v15 = *(_QWORD *)v13;
        *(_DWORD *)(v15 + 8) = v17;
        *(_QWORD *)(v15 + 16) = (*(__int64(__fastcall **)(__int64, __int64, INT64))(v16 + 8))(v16, v17, v15 + 24);
      }
    }
  }
  else
  {
    return(unsigned int)-2147483622;
  }
  return v1;
}

Referenced by:

CmpKeyEnumStackAdvance