CmpGetValueCountForKeyNodeStack

__int64 __fastcall CmpGetValueCountForKeyNodeStack(__int16 *a1, _DWORD *a2){
  __int16 v4; 
  INT64 *EntryAtLayerHeight; 
  char v6; 
  __int16 v7; 
  __int16 v8; 
  INT64 v9; 
  int v10; 
  int v11; 
  int v12; 
  int j; 
  int i; 
  INT16 result[48]; 
  INT64 v17[12]; 
  memset((INT64)result, 0i64);
  memset((INT64)v17, 0i64);
  CmpSortedValueEnumStackInitialize((INT64)result);
  CmpValueEnumStackInitialize(v17);
  v4 = *a1;
  if( *a1 < 0 )
    goto LABEL_23;
  do
  {
    EntryAtLayerHeight = (INT64 *)CmpKeyNodeStackGetEntryAtLayerHeight((INT64)a1, v4);
    v9 = EntryAtLayerHeight[2];
    if( v9 && (unsigned int)CmpGetEffectiveKeyNodeSemantics(*EntryAtLayerHeight, v9) )
      break;
    v4 = v7 - 1;
  }
  while( v4 >= 0 );
  if( !v8 )
  {
LABEL_23:
    *a2 = 0;
    goto LABEL_24;
  }
  if( !v6 )
  {
    *a2 = *(_DWORD *)(*(_QWORD *)(CmpKeyNodeStackGetEntryAtLayerHeight((INT64)a1, 0) + 16) + 36i64);
LABEL_24:
    v11 = 0;
    goto LABEL_25;
  }
  if( v8 <= 1 )
  {
LABEL_17:
    v11 = CmpValueEnumStackStartFromKeyNodeStack((__int64)v17, a1);
    if( v11 >= 0 )
    {
      v12 = 0;
      for( i = CmpValueEnumStackAdvance((INT64)v17); ; i = CmpValueEnumStackAdvance((INT64)v17) )
      {
        v11 = i;
        if( i == -2147483622 )
          break;
        if( i < 0 )
          goto LABEL_25;
        ++v12;
      }
      goto LABEL_14;
    }
    goto LABEL_25;
  }
  v10 = CmpSortedValueEnumStackStartFromKeyNodeStack((INT64)result, a1);
  v11 = v10;
  if( v10 >= 0 )
  {
    v12 = 0;
    for( j = CmpSortedValueEnumStackAdvance(result); ; j = CmpSortedValueEnumStackAdvance(result) )
    {
      v11 = j;
      if( j == -2147483622 )
        break;
      if( j < 0 )
        goto LABEL_25;
      ++v12;
    }
LABEL_14:
    *a2 = v12;
    goto LABEL_24;
  }
  if( v10 == -1073741670 )
  {
    CmpSortedValueEnumStackCleanup((INT64)result);
    CmpSortedValueEnumStackInitialize((INT64)result);
    goto LABEL_17;
  }
LABEL_25:
  CmpValueEnumStackCleanup((__int64)v17);
  CmpSortedValueEnumStackCleanup((INT64)result);
  return(unsigned int)v11;
}

Referenced by:

CmpQueryKeyDataFromKeyNodeStack