+ for (int i = 0; i < n_categories; i++)
+ dump_category (stream, level + 1, indexes, allocated_indexes, n_indexes);
+ for (int i = 0; i <= level; i++)
+ fprintf (stream, " ");
+ printf ("</category>\n");
+}
+
+static int
+dump_dim(int indx)
+{
+ int n_categories;
+
+ printf ("<dimension index=\"%d\">\n", indx);
+ dump_value (stdout, 0);
+
+ /* This byte is usually 0 but many other values have been spotted.
+ No visible effect. */
+ pos++;
+
+ /* This byte can cause data to be oddly replicated. */
+ if (!match_byte(0) && !match_byte(1))
+ match_byte_assert(2);
+
+ if (!match_u32(0))
+ match_u32_assert(2);
+
+ bool show_dim_label = get_bool();
+ if (show_dim_label)
+ printf(" <show-dim-label/>\n");
+
+ bool hide_all_labels = get_bool();
+ if (hide_all_labels)
+ printf(" <hide-all-labels/>\n");
+
+ match_byte_assert(1);
+ if (!match_u32(UINT32_MAX))
+ match_u32_assert(indx);
+
+ n_categories = get_u32();
+
+ int *indexes = NULL;
+ int n_indexes = 0;
+ int allocated_indexes = 0;
+ for (int i = 0; i < n_categories; i++)
+ dump_category (stdout, 0, &indexes, &allocated_indexes, &n_indexes);
+ check_permutation(indexes, n_indexes, "categories");
+
+ fprintf (stdout, "</dimension>\n");
+ return n_indexes;
+}
+
+int n_dims;
+static int dim_n_cats[64];
+#define MAX_DIMS (sizeof dim_n_cats / sizeof *dim_n_cats)
+
+static void
+dump_dims(void)
+{
+ n_dims = get_u32();
+ assert(n_dims < MAX_DIMS);
+ for (int i = 0; i < n_dims; i++)
+ dim_n_cats[i] = dump_dim (i);
+}
+
+static void
+dump_data(void)
+{
+ /* The first three numbers add to the number of dimensions. */
+ int l = get_u32();
+ int r = get_u32();
+ int c = n_dims - l - r;
+ match_u32_assert(c);
+
+ /* The next n_dims numbers are a permutation of the dimension numbers. */
+ int a[n_dims];
+ for (int i = 0; i < n_dims; i++)