/* binary.c generated by valac 0.56.19, the Vala compiler
 * generated from binary.vala, do not modify */

#include <glib-object.h>
#include "protonplus_core.h"
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <gobject/gvaluecollector.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

typedef enum  {
	PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_NODE = 0x00,
	PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_STRING = 0x01,
	PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_INT32 = 0x02,
	PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_FLOAT32 = 0x03,
	PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_POINTER = 0x04,
	PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_WIDESTRING = 0x05,
	PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_COLOR = 0x06,
	PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_UINT64 = 0x07,
	PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_END = 0x08,
	PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_INT64 = 0x0A,
	PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_END_ALT = 0x0B
} ProtonPlusUtilsVDFBIN_TYPES;

#define PROTON_PLUS_UTILS_VDF_TYPE_BIN_TYPES (proton_plus_utils_vdf_bin_types_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _proton_plus_utils_vdf_binary_unref0(var) ((var == NULL) ? NULL : (var = (proton_plus_utils_vdf_binary_unref (var), NULL)))
typedef struct _ProtonPlusUtilsVDFParamSpecBinary ProtonPlusUtilsVDFParamSpecBinary;

struct _ProtonPlusUtilsVDFBinaryPrivate {
	GeeTreeMap* _nodes;
	GFile* file;
	GDataInputStream* reader;
	GDataOutputStream* writer;
};

struct _ProtonPlusUtilsVDFParamSpecBinary {
	GParamSpec parent_instance;
};

static gint ProtonPlusUtilsVDFBinary_private_offset;
static gpointer proton_plus_utils_vdf_binary_parent_class = NULL;

VALA_EXTERN GType proton_plus_utils_vdf_bin_types_get_type (void) G_GNUC_CONST ;
static gchar* proton_plus_utils_vdf_binary_eat_string (ProtonPlusUtilsVDFBinary* self,
                                                GError** error);
static void proton_plus_utils_vdf_binary_parse_node (ProtonPlusUtilsVDFBinary* self,
                                              const gchar* current_node,
                                              GError** error);
static void proton_plus_utils_vdf_binary_get_data (ProtonPlusUtilsVDFBinary* self,
                                            ProtonPlusUtilsVDFNode* node,
                                            ProtonPlusUtilsVDFBIN_TYPES type,
                                            GError** error);
static guint proton_plus_utils_vdf_binary_count_dots (ProtonPlusUtilsVDFBinary* self,
                                               const gchar* str);
static void proton_plus_utils_vdf_binary_save_node (ProtonPlusUtilsVDFBinary* self,
                                             const gchar* node_name,
                                             guint layer,
                                             GeeSet* node_names,
                                             GError** error);
static void proton_plus_utils_vdf_binary_finalize (ProtonPlusUtilsVDFBinary * obj);
static GType proton_plus_utils_vdf_binary_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GType
proton_plus_utils_vdf_bin_types_get_type_once (void)
{
	static const GEnumValue values[] = {{PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_NODE, "PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_NODE", "bin-type-node"}, {PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_STRING, "PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_STRING", "bin-type-string"}, {PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_INT32, "PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_INT32", "bin-type-int32"}, {PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_FLOAT32, "PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_FLOAT32", "bin-type-float32"}, {PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_POINTER, "PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_POINTER", "bin-type-pointer"}, {PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_WIDESTRING, "PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_WIDESTRING", "bin-type-widestring"}, {PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_COLOR, "PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_COLOR", "bin-type-color"}, {PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_UINT64, "PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_UINT64", "bin-type-uint64"}, {PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_END, "PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_END", "bin-type-end"}, {PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_INT64, "PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_INT64", "bin-type-int64"}, {PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_END_ALT, "PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_END_ALT", "bin-type-end-alt"}, {0, NULL, NULL}};
	GType proton_plus_utils_vdf_bin_types_type_id;
	proton_plus_utils_vdf_bin_types_type_id = g_enum_register_static ("ProtonPlusUtilsVDFBIN_TYPES", values);
	return proton_plus_utils_vdf_bin_types_type_id;
}

GType
proton_plus_utils_vdf_bin_types_get_type (void)
{
	static volatile gsize proton_plus_utils_vdf_bin_types_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_vdf_bin_types_type_id__once)) {
		GType proton_plus_utils_vdf_bin_types_type_id;
		proton_plus_utils_vdf_bin_types_type_id = proton_plus_utils_vdf_bin_types_get_type_once ();
		g_once_init_leave (&proton_plus_utils_vdf_bin_types_type_id__once, proton_plus_utils_vdf_bin_types_type_id);
	}
	return proton_plus_utils_vdf_bin_types_type_id__once;
}

static inline gpointer
proton_plus_utils_vdf_binary_get_instance_private (ProtonPlusUtilsVDFBinary* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusUtilsVDFBinary_private_offset);
}

static gchar*
proton_plus_utils_vdf_binary_eat_string (ProtonPlusUtilsVDFBinary* self,
                                         GError** error)
{
	gsize len = 0UL;
	gchar* str = NULL;
	GDataInputStream* _tmp0_;
	gsize _tmp1_ = 0UL;
	gchar* _tmp2_;
	GDataInputStream* _tmp3_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->reader;
	_tmp2_ = g_data_input_stream_read_upto (_tmp0_, "\0", (gssize) 1, &_tmp1_, NULL, &_inner_error0_);
	len = _tmp1_;
	str = _tmp2_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp3_ = self->priv->reader;
	g_data_input_stream_read_byte (_tmp3_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_free0 (str);
		return NULL;
	}
	result = str;
	return result;
}

static void
proton_plus_utils_vdf_binary_parse_node (ProtonPlusUtilsVDFBinary* self,
                                         const gchar* current_node,
                                         GError** error)
{
	ProtonPlusUtilsVDFNode* node = NULL;
	ProtonPlusUtilsVDFNode* _tmp0_;
	GeeTreeMap* _tmp1_;
	ProtonPlusUtilsVDFNode* _tmp2_;
	const gchar* _tmp3_;
	ProtonPlusUtilsVDFNode* _tmp4_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (current_node != NULL);
	_tmp0_ = proton_plus_utils_vdf_node_new (current_node);
	node = _tmp0_;
	_tmp1_ = self->priv->_nodes;
	_tmp2_ = node;
	_tmp3_ = _tmp2_->node_name;
	_tmp4_ = node;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp1_, _tmp3_, _tmp4_);
	while (TRUE) {
		guint8 type = 0U;
		GDataInputStream* _tmp5_;
		_tmp5_ = self->priv->reader;
		type = g_data_input_stream_read_byte (_tmp5_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (node);
			return;
		}
		switch (type) {
			case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_NODE:
			{
				gchar* _tmp6_ = NULL;
				gchar* _tmp7_;
				gchar* _tmp8_;
				gchar* _tmp9_;
				gchar* _tmp10_;
				gchar* _tmp11_;
				_tmp7_ = proton_plus_utils_vdf_binary_eat_string (self, &_inner_error0_);
				_tmp6_ = _tmp7_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (node);
					return;
				}
				_tmp8_ = g_strconcat (current_node, ".", NULL);
				_tmp9_ = _tmp8_;
				_tmp10_ = g_strconcat (_tmp9_, _tmp6_, NULL);
				_tmp11_ = _tmp10_;
				proton_plus_utils_vdf_binary_parse_node (self, _tmp11_, &_inner_error0_);
				_g_free0 (_tmp11_);
				_g_free0 (_tmp9_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_free0 (_tmp6_);
					_g_object_unref0 (node);
					return;
				}
				_g_free0 (_tmp6_);
				break;
			}
			case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_STRING:
			case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_INT32:
			case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_FLOAT32:
			case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_POINTER:
			case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_WIDESTRING:
			case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_COLOR:
			case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_UINT64:
			case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_INT64:
			{
				ProtonPlusUtilsVDFNode* _tmp12_;
				_tmp12_ = node;
				proton_plus_utils_vdf_binary_get_data (self, _tmp12_, type, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (node);
					return;
				}
				break;
			}
			case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_END:
			case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_END_ALT:
			{
				_g_object_unref0 (node);
				return;
			}
			default:
			{
				GError* _tmp13_;
				_tmp13_ = g_error_new (g_quark_from_string ("vala-vdf"), 0, "Unexpected byte");
				_inner_error0_ = _tmp13_;
				g_propagate_error (error, _inner_error0_);
				_g_object_unref0 (node);
				return;
			}
		}
	}
}

static void
proton_plus_utils_vdf_binary_get_data (ProtonPlusUtilsVDFBinary* self,
                                       ProtonPlusUtilsVDFNode* node,
                                       ProtonPlusUtilsVDFBIN_TYPES type,
                                       GError** error)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	switch (type) {
		case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_STRING:
		case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_WIDESTRING:
		{
			gchar* _tmp0_ = NULL;
			gchar* _tmp1_;
			gchar* _tmp2_ = NULL;
			gchar* _tmp3_;
			GVariant* _tmp4_;
			GVariant* _tmp5_;
			_tmp1_ = proton_plus_utils_vdf_binary_eat_string (self, &_inner_error0_);
			_tmp0_ = _tmp1_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				return;
			}
			_tmp3_ = proton_plus_utils_vdf_binary_eat_string (self, &_inner_error0_);
			_tmp2_ = _tmp3_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_g_free0 (_tmp0_);
				return;
			}
			_tmp4_ = g_variant_new_string (_tmp2_);
			g_variant_ref_sink (_tmp4_);
			_tmp5_ = _tmp4_;
			gee_abstract_map_set ((GeeAbstractMap*) node, _tmp0_, _tmp5_);
			_g_variant_unref0 (_tmp5_);
			_g_free0 (_tmp2_);
			_g_free0 (_tmp0_);
			break;
		}
		case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_INT32:
		{
			gchar* _tmp6_ = NULL;
			gchar* _tmp7_;
			gint32 _tmp8_ = 0;
			GDataInputStream* _tmp9_;
			GVariant* _tmp10_;
			GVariant* _tmp11_;
			_tmp7_ = proton_plus_utils_vdf_binary_eat_string (self, &_inner_error0_);
			_tmp6_ = _tmp7_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				return;
			}
			_tmp9_ = self->priv->reader;
			_tmp8_ = g_data_input_stream_read_int32 (_tmp9_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_g_free0 (_tmp6_);
				return;
			}
			_tmp10_ = g_variant_new_int32 (_tmp8_);
			g_variant_ref_sink (_tmp10_);
			_tmp11_ = _tmp10_;
			gee_abstract_map_set ((GeeAbstractMap*) node, _tmp6_, _tmp11_);
			_g_variant_unref0 (_tmp11_);
			_g_free0 (_tmp6_);
			break;
		}
		case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_FLOAT32:
		{
			GError* _tmp12_;
			_tmp12_ = g_error_new (g_quark_from_string ("vala-vdf"), 0, "Floats not supported yet");
			_inner_error0_ = _tmp12_;
			g_propagate_error (error, _inner_error0_);
			return;
		}
		case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_POINTER:
		{
			GError* _tmp13_;
			_tmp13_ = g_error_new (g_quark_from_string ("vala-vdf"), 0, "Pointers not supported yet");
			_inner_error0_ = _tmp13_;
			g_propagate_error (error, _inner_error0_);
			return;
		}
		case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_COLOR:
		{
			GError* _tmp14_;
			_tmp14_ = g_error_new (g_quark_from_string ("vala-vdf"), 0, "Colors not supported yet");
			_inner_error0_ = _tmp14_;
			g_propagate_error (error, _inner_error0_);
			return;
		}
		case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_UINT64:
		{
			gchar* _tmp15_ = NULL;
			gchar* _tmp16_;
			guint64 _tmp17_ = 0ULL;
			GDataInputStream* _tmp18_;
			GVariant* _tmp19_;
			GVariant* _tmp20_;
			_tmp16_ = proton_plus_utils_vdf_binary_eat_string (self, &_inner_error0_);
			_tmp15_ = _tmp16_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				return;
			}
			_tmp18_ = self->priv->reader;
			_tmp17_ = g_data_input_stream_read_uint64 (_tmp18_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_g_free0 (_tmp15_);
				return;
			}
			_tmp19_ = g_variant_new_uint64 (_tmp17_);
			g_variant_ref_sink (_tmp19_);
			_tmp20_ = _tmp19_;
			gee_abstract_map_set ((GeeAbstractMap*) node, _tmp15_, _tmp20_);
			_g_variant_unref0 (_tmp20_);
			_g_free0 (_tmp15_);
			break;
		}
		case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_INT64:
		{
			gchar* _tmp21_ = NULL;
			gchar* _tmp22_;
			gint64 _tmp23_ = 0LL;
			GDataInputStream* _tmp24_;
			GVariant* _tmp25_;
			GVariant* _tmp26_;
			_tmp22_ = proton_plus_utils_vdf_binary_eat_string (self, &_inner_error0_);
			_tmp21_ = _tmp22_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				return;
			}
			_tmp24_ = self->priv->reader;
			_tmp23_ = g_data_input_stream_read_int64 (_tmp24_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_g_free0 (_tmp21_);
				return;
			}
			_tmp25_ = g_variant_new_int64 (_tmp23_);
			g_variant_ref_sink (_tmp25_);
			_tmp26_ = _tmp25_;
			gee_abstract_map_set ((GeeAbstractMap*) node, _tmp21_, _tmp26_);
			_g_variant_unref0 (_tmp26_);
			_g_free0 (_tmp21_);
			break;
		}
		default:
		{
			GError* _tmp27_;
			_tmp27_ = g_error_new (g_quark_from_string ("vala-vdf"), 0, "Unexpected byte");
			_inner_error0_ = _tmp27_;
			g_propagate_error (error, _inner_error0_);
			return;
		}
	}
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

static guint
proton_plus_utils_vdf_binary_count_dots (ProtonPlusUtilsVDFBinary* self,
                                         const gchar* str)
{
	guint ret = 0U;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	g_return_val_if_fail (str != NULL, 0U);
	ret = (guint) 0;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gint _tmp2_;
				gint _tmp3_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = strlen (str);
				_tmp3_ = _tmp2_;
				if (!(i < _tmp3_)) {
					break;
				}
				if (string_get (str, (glong) i) == '.') {
					guint _tmp4_;
					_tmp4_ = ret;
					ret = _tmp4_ + 1;
				}
			}
		}
	}
	result = ret;
	return result;
}

static void
proton_plus_utils_vdf_binary_save_node (ProtonPlusUtilsVDFBinary* self,
                                        const gchar* node_name,
                                        guint layer,
                                        GeeSet* node_names,
                                        GError** error)
{
	GDataOutputStream* _tmp0_;
	gchar** split_name = NULL;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint split_name_length1;
	gint _split_name_size_;
	GDataOutputStream* _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	gchar** _tmp5_;
	gint _tmp5__length1;
	const gchar* _tmp6_;
	GDataOutputStream* _tmp7_;
	ProtonPlusUtilsVDFNode* node = NULL;
	GeeTreeMap* _tmp8_;
	gpointer _tmp9_;
	GDataOutputStream* _tmp88_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node_name != NULL);
	g_return_if_fail (node_names != NULL);
	_tmp0_ = self->priv->writer;
	g_data_output_stream_put_byte (_tmp0_, (guint8) PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_NODE, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp2_ = _tmp1_ = g_strsplit (node_name, ".", 0);
	split_name = _tmp2_;
	split_name_length1 = _vala_array_length (_tmp1_);
	_split_name_size_ = split_name_length1;
	_tmp3_ = self->priv->writer;
	_tmp4_ = split_name;
	_tmp4__length1 = split_name_length1;
	_tmp5_ = split_name;
	_tmp5__length1 = split_name_length1;
	_tmp6_ = _tmp4_[_tmp5__length1 - 1];
	g_data_output_stream_put_string (_tmp3_, _tmp6_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
		return;
	}
	_tmp7_ = self->priv->writer;
	g_data_output_stream_put_byte (_tmp7_, (guint8) '\0', NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
		return;
	}
	_tmp8_ = self->priv->_nodes;
	_tmp9_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp8_, node_name);
	node = (ProtonPlusUtilsVDFNode*) _tmp9_;
	{
		GeeIterator* _elem_it = NULL;
		ProtonPlusUtilsVDFNode* _tmp10_;
		GeeSet* _tmp11_;
		GeeSet* _tmp12_;
		GeeSet* _tmp13_;
		GeeIterator* _tmp14_;
		GeeIterator* _tmp15_;
		_tmp10_ = node;
		_tmp11_ = gee_abstract_map_get_entries ((GeeAbstractMap*) _tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = _tmp12_;
		_tmp14_ = gee_iterable_iterator ((GeeIterable*) _tmp13_);
		_tmp15_ = _tmp14_;
		_g_object_unref0 (_tmp13_);
		_elem_it = _tmp15_;
		while (TRUE) {
			GeeIterator* _tmp16_;
			GeeMapEntry* elem = NULL;
			GeeIterator* _tmp17_;
			gpointer _tmp18_;
			GeeMapEntry* _tmp19_;
			gconstpointer _tmp20_;
			gconstpointer _tmp21_;
			const GVariantType* _tmp22_;
			_tmp16_ = _elem_it;
			if (!gee_iterator_next (_tmp16_)) {
				break;
			}
			_tmp17_ = _elem_it;
			_tmp18_ = gee_iterator_get (_tmp17_);
			elem = (GeeMapEntry*) _tmp18_;
			_tmp19_ = elem;
			_tmp20_ = gee_map_entry_get_value (_tmp19_);
			_tmp21_ = _tmp20_;
			_tmp22_ = G_VARIANT_TYPE_STRING;
			if (g_variant_is_of_type ((GVariant*) _tmp21_, _tmp22_)) {
				GDataOutputStream* _tmp23_;
				GDataOutputStream* _tmp24_;
				GeeMapEntry* _tmp25_;
				gconstpointer _tmp26_;
				gconstpointer _tmp27_;
				GDataOutputStream* _tmp28_;
				GDataOutputStream* _tmp29_;
				GeeMapEntry* _tmp30_;
				gconstpointer _tmp31_;
				gconstpointer _tmp32_;
				const gchar* _tmp33_;
				GDataOutputStream* _tmp34_;
				_tmp23_ = self->priv->writer;
				g_data_output_stream_put_byte (_tmp23_, (guint8) PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_STRING, NULL, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (elem);
					_g_object_unref0 (_elem_it);
					_g_object_unref0 (node);
					split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
					return;
				}
				_tmp24_ = self->priv->writer;
				_tmp25_ = elem;
				_tmp26_ = gee_map_entry_get_key (_tmp25_);
				_tmp27_ = _tmp26_;
				g_data_output_stream_put_string (_tmp24_, (const gchar*) _tmp27_, NULL, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (elem);
					_g_object_unref0 (_elem_it);
					_g_object_unref0 (node);
					split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
					return;
				}
				_tmp28_ = self->priv->writer;
				g_data_output_stream_put_byte (_tmp28_, (guint8) '\0', NULL, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (elem);
					_g_object_unref0 (_elem_it);
					_g_object_unref0 (node);
					split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
					return;
				}
				_tmp29_ = self->priv->writer;
				_tmp30_ = elem;
				_tmp31_ = gee_map_entry_get_value (_tmp30_);
				_tmp32_ = _tmp31_;
				_tmp33_ = g_variant_get_string ((GVariant*) _tmp32_, NULL);
				g_data_output_stream_put_string (_tmp29_, _tmp33_, NULL, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (elem);
					_g_object_unref0 (_elem_it);
					_g_object_unref0 (node);
					split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
					return;
				}
				_tmp34_ = self->priv->writer;
				g_data_output_stream_put_byte (_tmp34_, (guint8) '\0', NULL, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (elem);
					_g_object_unref0 (_elem_it);
					_g_object_unref0 (node);
					split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
					return;
				}
			} else {
				GeeMapEntry* _tmp35_;
				gconstpointer _tmp36_;
				gconstpointer _tmp37_;
				const GVariantType* _tmp38_;
				_tmp35_ = elem;
				_tmp36_ = gee_map_entry_get_value (_tmp35_);
				_tmp37_ = _tmp36_;
				_tmp38_ = G_VARIANT_TYPE_UINT64;
				if (g_variant_is_of_type ((GVariant*) _tmp37_, _tmp38_)) {
					GDataOutputStream* _tmp39_;
					GDataOutputStream* _tmp40_;
					GeeMapEntry* _tmp41_;
					gconstpointer _tmp42_;
					gconstpointer _tmp43_;
					GDataOutputStream* _tmp44_;
					GDataOutputStream* _tmp45_;
					GeeMapEntry* _tmp46_;
					gconstpointer _tmp47_;
					gconstpointer _tmp48_;
					_tmp39_ = self->priv->writer;
					g_data_output_stream_put_byte (_tmp39_, (guint8) PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_UINT64, NULL, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						_g_object_unref0 (elem);
						_g_object_unref0 (_elem_it);
						_g_object_unref0 (node);
						split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
						return;
					}
					_tmp40_ = self->priv->writer;
					_tmp41_ = elem;
					_tmp42_ = gee_map_entry_get_key (_tmp41_);
					_tmp43_ = _tmp42_;
					g_data_output_stream_put_string (_tmp40_, (const gchar*) _tmp43_, NULL, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						_g_object_unref0 (elem);
						_g_object_unref0 (_elem_it);
						_g_object_unref0 (node);
						split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
						return;
					}
					_tmp44_ = self->priv->writer;
					g_data_output_stream_put_byte (_tmp44_, (guint8) '\0', NULL, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						_g_object_unref0 (elem);
						_g_object_unref0 (_elem_it);
						_g_object_unref0 (node);
						split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
						return;
					}
					_tmp45_ = self->priv->writer;
					_tmp46_ = elem;
					_tmp47_ = gee_map_entry_get_value (_tmp46_);
					_tmp48_ = _tmp47_;
					g_data_output_stream_put_uint64 (_tmp45_, g_variant_get_uint64 ((GVariant*) _tmp48_), NULL, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						_g_object_unref0 (elem);
						_g_object_unref0 (_elem_it);
						_g_object_unref0 (node);
						split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
						return;
					}
				} else {
					GeeMapEntry* _tmp49_;
					gconstpointer _tmp50_;
					gconstpointer _tmp51_;
					const GVariantType* _tmp52_;
					_tmp49_ = elem;
					_tmp50_ = gee_map_entry_get_value (_tmp49_);
					_tmp51_ = _tmp50_;
					_tmp52_ = G_VARIANT_TYPE_INT64;
					if (g_variant_is_of_type ((GVariant*) _tmp51_, _tmp52_)) {
						GDataOutputStream* _tmp53_;
						GDataOutputStream* _tmp54_;
						GeeMapEntry* _tmp55_;
						gconstpointer _tmp56_;
						gconstpointer _tmp57_;
						GDataOutputStream* _tmp58_;
						GDataOutputStream* _tmp59_;
						GeeMapEntry* _tmp60_;
						gconstpointer _tmp61_;
						gconstpointer _tmp62_;
						_tmp53_ = self->priv->writer;
						g_data_output_stream_put_byte (_tmp53_, (guint8) PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_INT64, NULL, &_inner_error0_);
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							g_propagate_error (error, _inner_error0_);
							_g_object_unref0 (elem);
							_g_object_unref0 (_elem_it);
							_g_object_unref0 (node);
							split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
							return;
						}
						_tmp54_ = self->priv->writer;
						_tmp55_ = elem;
						_tmp56_ = gee_map_entry_get_key (_tmp55_);
						_tmp57_ = _tmp56_;
						g_data_output_stream_put_string (_tmp54_, (const gchar*) _tmp57_, NULL, &_inner_error0_);
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							g_propagate_error (error, _inner_error0_);
							_g_object_unref0 (elem);
							_g_object_unref0 (_elem_it);
							_g_object_unref0 (node);
							split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
							return;
						}
						_tmp58_ = self->priv->writer;
						g_data_output_stream_put_byte (_tmp58_, (guint8) '\0', NULL, &_inner_error0_);
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							g_propagate_error (error, _inner_error0_);
							_g_object_unref0 (elem);
							_g_object_unref0 (_elem_it);
							_g_object_unref0 (node);
							split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
							return;
						}
						_tmp59_ = self->priv->writer;
						_tmp60_ = elem;
						_tmp61_ = gee_map_entry_get_value (_tmp60_);
						_tmp62_ = _tmp61_;
						g_data_output_stream_put_int64 (_tmp59_, g_variant_get_int64 ((GVariant*) _tmp62_), NULL, &_inner_error0_);
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							g_propagate_error (error, _inner_error0_);
							_g_object_unref0 (elem);
							_g_object_unref0 (_elem_it);
							_g_object_unref0 (node);
							split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
							return;
						}
					} else {
						GeeMapEntry* _tmp63_;
						gconstpointer _tmp64_;
						gconstpointer _tmp65_;
						const GVariantType* _tmp66_;
						_tmp63_ = elem;
						_tmp64_ = gee_map_entry_get_value (_tmp63_);
						_tmp65_ = _tmp64_;
						_tmp66_ = G_VARIANT_TYPE_INT32;
						if (g_variant_is_of_type ((GVariant*) _tmp65_, _tmp66_)) {
							GDataOutputStream* _tmp67_;
							GDataOutputStream* _tmp68_;
							GeeMapEntry* _tmp69_;
							gconstpointer _tmp70_;
							gconstpointer _tmp71_;
							GDataOutputStream* _tmp72_;
							GDataOutputStream* _tmp73_;
							GeeMapEntry* _tmp74_;
							gconstpointer _tmp75_;
							gconstpointer _tmp76_;
							_tmp67_ = self->priv->writer;
							g_data_output_stream_put_byte (_tmp67_, (guint8) PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_INT32, NULL, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								g_propagate_error (error, _inner_error0_);
								_g_object_unref0 (elem);
								_g_object_unref0 (_elem_it);
								_g_object_unref0 (node);
								split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
								return;
							}
							_tmp68_ = self->priv->writer;
							_tmp69_ = elem;
							_tmp70_ = gee_map_entry_get_key (_tmp69_);
							_tmp71_ = _tmp70_;
							g_data_output_stream_put_string (_tmp68_, (const gchar*) _tmp71_, NULL, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								g_propagate_error (error, _inner_error0_);
								_g_object_unref0 (elem);
								_g_object_unref0 (_elem_it);
								_g_object_unref0 (node);
								split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
								return;
							}
							_tmp72_ = self->priv->writer;
							g_data_output_stream_put_byte (_tmp72_, (guint8) '\0', NULL, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								g_propagate_error (error, _inner_error0_);
								_g_object_unref0 (elem);
								_g_object_unref0 (_elem_it);
								_g_object_unref0 (node);
								split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
								return;
							}
							_tmp73_ = self->priv->writer;
							_tmp74_ = elem;
							_tmp75_ = gee_map_entry_get_value (_tmp74_);
							_tmp76_ = _tmp75_;
							g_data_output_stream_put_int32 (_tmp73_, g_variant_get_int32 ((GVariant*) _tmp76_), NULL, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								g_propagate_error (error, _inner_error0_);
								_g_object_unref0 (elem);
								_g_object_unref0 (_elem_it);
								_g_object_unref0 (node);
								split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
								return;
							}
						}
					}
				}
			}
			_g_object_unref0 (elem);
		}
		_g_object_unref0 (_elem_it);
	}
	{
		GeeIterator* _child_name_it = NULL;
		GeeIterator* _tmp77_;
		_tmp77_ = gee_iterable_iterator ((GeeIterable*) node_names);
		_child_name_it = _tmp77_;
		while (TRUE) {
			GeeIterator* _tmp78_;
			gchar* child_name = NULL;
			GeeIterator* _tmp79_;
			gpointer _tmp80_;
			gboolean _tmp81_ = FALSE;
			const gchar* _tmp82_;
			gchar* _tmp83_;
			gchar* _tmp84_;
			gboolean _tmp85_;
			_tmp78_ = _child_name_it;
			if (!gee_iterator_next (_tmp78_)) {
				break;
			}
			_tmp79_ = _child_name_it;
			_tmp80_ = gee_iterator_get (_tmp79_);
			child_name = (gchar*) _tmp80_;
			_tmp82_ = child_name;
			_tmp83_ = g_strconcat (node_name, ".", NULL);
			_tmp84_ = _tmp83_;
			_tmp85_ = g_str_has_prefix (_tmp82_, _tmp84_);
			_g_free0 (_tmp84_);
			if (_tmp85_) {
				const gchar* _tmp86_;
				_tmp86_ = child_name;
				_tmp81_ = proton_plus_utils_vdf_binary_count_dots (self, _tmp86_) == (layer + 1);
			} else {
				_tmp81_ = FALSE;
			}
			if (_tmp81_) {
				const gchar* _tmp87_;
				_tmp87_ = child_name;
				proton_plus_utils_vdf_binary_save_node (self, _tmp87_, layer + 1, node_names, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_free0 (child_name);
					_g_object_unref0 (_child_name_it);
					_g_object_unref0 (node);
					split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
					return;
				}
			}
			_g_free0 (child_name);
		}
		_g_object_unref0 (_child_name_it);
	}
	_tmp88_ = self->priv->writer;
	g_data_output_stream_put_byte (_tmp88_, (guint8) PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_END, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (node);
		split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
		return;
	}
	_g_object_unref0 (node);
	split_name = (_vala_array_free (split_name, split_name_length1, (GDestroyNotify) g_free), NULL);
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

void
proton_plus_utils_vdf_binary_save (ProtonPlusUtilsVDFBinary* self,
                                   GError** error)
{
	GFileOutputStream* output_stream = NULL;
	GFile* _tmp0_;
	GFileOutputStream* _tmp1_;
	GFileOutputStream* _tmp2_;
	GDataOutputStream* _tmp3_;
	GDataOutputStream* _tmp4_;
	GeeSet* node_names = NULL;
	GeeTreeMap* _tmp5_;
	GeeSet* _tmp6_;
	GeeSet* _tmp7_;
	GDataOutputStream* _tmp16_;
	GFileOutputStream* _tmp17_;
	GFileOutputStream* _tmp18_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->file;
	_tmp1_ = g_file_replace (_tmp0_, NULL, FALSE, G_FILE_CREATE_PRIVATE, NULL, &_inner_error0_);
	output_stream = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp2_ = output_stream;
	_tmp3_ = g_data_output_stream_new ((GOutputStream*) _tmp2_);
	_g_object_unref0 (self->priv->writer);
	self->priv->writer = _tmp3_;
	_tmp4_ = self->priv->writer;
	g_data_output_stream_set_byte_order (_tmp4_, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN);
	_tmp5_ = self->priv->_nodes;
	_tmp6_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp5_);
	_tmp7_ = _tmp6_;
	node_names = _tmp7_;
	{
		GeeIterator* _node_name_it = NULL;
		GeeSet* _tmp8_;
		GeeIterator* _tmp9_;
		_tmp8_ = node_names;
		_tmp9_ = gee_iterable_iterator ((GeeIterable*) _tmp8_);
		_node_name_it = _tmp9_;
		while (TRUE) {
			GeeIterator* _tmp10_;
			gchar* node_name = NULL;
			GeeIterator* _tmp11_;
			gpointer _tmp12_;
			const gchar* _tmp13_;
			_tmp10_ = _node_name_it;
			if (!gee_iterator_next (_tmp10_)) {
				break;
			}
			_tmp11_ = _node_name_it;
			_tmp12_ = gee_iterator_get (_tmp11_);
			node_name = (gchar*) _tmp12_;
			_tmp13_ = node_name;
			if (!string_contains (_tmp13_, ".")) {
				const gchar* _tmp14_;
				GeeSet* _tmp15_;
				_tmp14_ = node_name;
				_tmp15_ = node_names;
				proton_plus_utils_vdf_binary_save_node (self, _tmp14_, (guint) 0, _tmp15_, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_free0 (node_name);
					_g_object_unref0 (_node_name_it);
					_g_object_unref0 (node_names);
					_g_object_unref0 (output_stream);
					return;
				}
			}
			_g_free0 (node_name);
		}
		_g_object_unref0 (_node_name_it);
	}
	_tmp16_ = self->priv->writer;
	g_data_output_stream_put_byte (_tmp16_, (guint8) PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_END, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (node_names);
		_g_object_unref0 (output_stream);
		return;
	}
	_tmp17_ = output_stream;
	g_output_stream_flush ((GOutputStream*) _tmp17_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (node_names);
		_g_object_unref0 (output_stream);
		return;
	}
	_tmp18_ = output_stream;
	g_output_stream_close ((GOutputStream*) _tmp18_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (node_names);
		_g_object_unref0 (output_stream);
		return;
	}
	_g_object_unref0 (node_names);
	_g_object_unref0 (output_stream);
}

ProtonPlusUtilsVDFBinary*
proton_plus_utils_vdf_binary_construct (GType object_type,
                                        const gchar* path)
{
	ProtonPlusUtilsVDFBinary* self = NULL;
	GFile* _tmp0_;
	GeeTreeMap* _tmp1_;
	GeeTreeMap* _tmp2_;
	g_return_val_if_fail (path != NULL, NULL);
	self = (ProtonPlusUtilsVDFBinary*) g_type_create_instance (object_type);
	_tmp0_ = g_file_new_for_path (path);
	_g_object_unref0 (self->priv->file);
	self->priv->file = _tmp0_;
	_tmp1_ = gee_tree_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, PROTON_PLUS_UTILS_VDF_TYPE_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_tmp2_ = _tmp1_;
	proton_plus_utils_vdf_binary_set_nodes (self, _tmp2_);
	_g_object_unref0 (_tmp2_);
	return self;
}

ProtonPlusUtilsVDFBinary*
proton_plus_utils_vdf_binary_new (const gchar* path)
{
	return proton_plus_utils_vdf_binary_construct (PROTON_PLUS_UTILS_VDF_TYPE_BINARY, path);
}

static gpointer
_g_error_copy0 (gpointer self)
{
	return self ? g_error_copy (self) : NULL;
}

void
proton_plus_utils_vdf_binary_parse (ProtonPlusUtilsVDFBinary* self,
                                    GError** error)
{
	GFileInputStream* input_stream = NULL;
	GFile* _tmp0_;
	GFileInputStream* _tmp1_;
	GFileInputStream* _tmp12_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->file;
	_tmp1_ = g_file_read (_tmp0_, NULL, &_inner_error0_);
	input_stream = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	{
		GFileInputStream* _tmp2_;
		GDataInputStream* _tmp3_;
		GDataInputStream* _tmp4_;
		gboolean complete = FALSE;
		_tmp2_ = input_stream;
		_tmp3_ = g_data_input_stream_new ((GInputStream*) _tmp2_);
		_g_object_unref0 (self->priv->reader);
		self->priv->reader = _tmp3_;
		_tmp4_ = self->priv->reader;
		g_data_input_stream_set_byte_order (_tmp4_, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN);
		complete = FALSE;
		while (TRUE) {
			guint8 type = 0U;
			GDataInputStream* _tmp5_;
			if (!(!complete)) {
				break;
			}
			_tmp5_ = self->priv->reader;
			type = g_data_input_stream_read_byte (_tmp5_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			switch (type) {
				case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_NODE:
				{
					gchar* _tmp6_ = NULL;
					gchar* _tmp7_;
					_tmp7_ = proton_plus_utils_vdf_binary_eat_string (self, &_inner_error0_);
					_tmp6_ = _tmp7_;
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
					proton_plus_utils_vdf_binary_parse_node (self, _tmp6_, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						_g_free0 (_tmp6_);
						goto __catch0_g_error;
					}
					_g_free0 (_tmp6_);
					break;
				}
				case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_END:
				case PROTON_PLUS_UTILS_VDF_BIN_TYPES_BIN_TYPE_END_ALT:
				{
					complete = TRUE;
					break;
				}
				default:
				{
					GError* _tmp8_;
					_tmp8_ = g_error_new (g_quark_from_string ("vala-vdf"), 0, "Unexpected byte");
					_inner_error0_ = _tmp8_;
					goto __catch0_g_error;
				}
			}
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GFileInputStream* _tmp9_;
		GError* _tmp10_;
		GError* _tmp11_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp9_ = input_stream;
		g_input_stream_close ((GInputStream*) _tmp9_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_error_free0 (e);
			goto __finally0;
		}
		_tmp10_ = e;
		_tmp11_ = _g_error_copy0 (_tmp10_);
		_inner_error0_ = _tmp11_;
		_g_error_free0 (e);
		goto __finally0;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (input_stream);
		return;
	}
	_tmp12_ = input_stream;
	g_input_stream_close ((GInputStream*) _tmp12_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (input_stream);
		return;
	}
	_g_object_unref0 (input_stream);
}

ProtonPlusUtilsVDFBinary*
proton_plus_utils_vdf_binary_load (const gchar* path,
                                   GError** error)
{
	ProtonPlusUtilsVDFBinary* binary = NULL;
	ProtonPlusUtilsVDFBinary* _tmp0_;
	GError* _inner_error0_ = NULL;
	ProtonPlusUtilsVDFBinary* result;
	g_return_val_if_fail (path != NULL, NULL);
	_tmp0_ = proton_plus_utils_vdf_binary_new (path);
	binary = _tmp0_;
	proton_plus_utils_vdf_binary_parse (binary, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_proton_plus_utils_vdf_binary_unref0 (binary);
		return NULL;
	}
	result = binary;
	return result;
}

GeeTreeMap*
proton_plus_utils_vdf_binary_get_nodes (ProtonPlusUtilsVDFBinary* self)
{
	GeeTreeMap* result;
	GeeTreeMap* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_nodes;
	result = _tmp0_;
	return result;
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

void
proton_plus_utils_vdf_binary_set_nodes (ProtonPlusUtilsVDFBinary* self,
                                        GeeTreeMap* value)
{
	GeeTreeMap* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_nodes);
	self->priv->_nodes = _tmp0_;
}

static void
proton_plus_utils_vdf_value_binary_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
proton_plus_utils_vdf_value_binary_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		proton_plus_utils_vdf_binary_unref (value->data[0].v_pointer);
	}
}

static void
proton_plus_utils_vdf_value_binary_copy_value (const GValue* src_value,
                                               GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = proton_plus_utils_vdf_binary_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
proton_plus_utils_vdf_value_binary_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
proton_plus_utils_vdf_value_binary_collect_value (GValue* value,
                                                  guint n_collect_values,
                                                  GTypeCValue* collect_values,
                                                  guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		ProtonPlusUtilsVDFBinary * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = proton_plus_utils_vdf_binary_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
proton_plus_utils_vdf_value_binary_lcopy_value (const GValue* value,
                                                guint n_collect_values,
                                                GTypeCValue* collect_values,
                                                guint collect_flags)
{
	ProtonPlusUtilsVDFBinary ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = proton_plus_utils_vdf_binary_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
proton_plus_utils_vdf_param_spec_binary (const gchar* name,
                                         const gchar* nick,
                                         const gchar* blurb,
                                         GType object_type,
                                         GParamFlags flags)
{
	ProtonPlusUtilsVDFParamSpecBinary* spec;
	g_return_val_if_fail (g_type_is_a (object_type, PROTON_PLUS_UTILS_VDF_TYPE_BINARY), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
proton_plus_utils_vdf_value_get_binary (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PROTON_PLUS_UTILS_VDF_TYPE_BINARY), NULL);
	return value->data[0].v_pointer;
}

void
proton_plus_utils_vdf_value_set_binary (GValue* value,
                                        gpointer v_object)
{
	ProtonPlusUtilsVDFBinary * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PROTON_PLUS_UTILS_VDF_TYPE_BINARY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, PROTON_PLUS_UTILS_VDF_TYPE_BINARY));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		proton_plus_utils_vdf_binary_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		proton_plus_utils_vdf_binary_unref (old);
	}
}

void
proton_plus_utils_vdf_value_take_binary (GValue* value,
                                         gpointer v_object)
{
	ProtonPlusUtilsVDFBinary * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PROTON_PLUS_UTILS_VDF_TYPE_BINARY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, PROTON_PLUS_UTILS_VDF_TYPE_BINARY));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		proton_plus_utils_vdf_binary_unref (old);
	}
}

static void
proton_plus_utils_vdf_binary_class_init (ProtonPlusUtilsVDFBinaryClass * klass,
                                         gpointer klass_data)
{
	proton_plus_utils_vdf_binary_parent_class = g_type_class_peek_parent (klass);
	((ProtonPlusUtilsVDFBinaryClass *) klass)->finalize = proton_plus_utils_vdf_binary_finalize;
	g_type_class_adjust_private_offset (klass, &ProtonPlusUtilsVDFBinary_private_offset);
}

static void
proton_plus_utils_vdf_binary_instance_init (ProtonPlusUtilsVDFBinary * self,
                                            gpointer klass)
{
	self->priv = proton_plus_utils_vdf_binary_get_instance_private (self);
	self->ref_count = 1;
}

static void
proton_plus_utils_vdf_binary_finalize (ProtonPlusUtilsVDFBinary * obj)
{
	ProtonPlusUtilsVDFBinary * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_UTILS_VDF_TYPE_BINARY, ProtonPlusUtilsVDFBinary);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->_nodes);
	_g_object_unref0 (self->priv->file);
	_g_object_unref0 (self->priv->reader);
	_g_object_unref0 (self->priv->writer);
}

static GType
proton_plus_utils_vdf_binary_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { proton_plus_utils_vdf_value_binary_init, proton_plus_utils_vdf_value_binary_free_value, proton_plus_utils_vdf_value_binary_copy_value, proton_plus_utils_vdf_value_binary_peek_pointer, "p", proton_plus_utils_vdf_value_binary_collect_value, "p", proton_plus_utils_vdf_value_binary_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusUtilsVDFBinaryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_utils_vdf_binary_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusUtilsVDFBinary), 0, (GInstanceInitFunc) proton_plus_utils_vdf_binary_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType proton_plus_utils_vdf_binary_type_id;
	proton_plus_utils_vdf_binary_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ProtonPlusUtilsVDFBinary", &g_define_type_info, &g_define_type_fundamental_info, 0);
	ProtonPlusUtilsVDFBinary_private_offset = g_type_add_instance_private (proton_plus_utils_vdf_binary_type_id, sizeof (ProtonPlusUtilsVDFBinaryPrivate));
	return proton_plus_utils_vdf_binary_type_id;
}

GType
proton_plus_utils_vdf_binary_get_type (void)
{
	static volatile gsize proton_plus_utils_vdf_binary_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_vdf_binary_type_id__once)) {
		GType proton_plus_utils_vdf_binary_type_id;
		proton_plus_utils_vdf_binary_type_id = proton_plus_utils_vdf_binary_get_type_once ();
		g_once_init_leave (&proton_plus_utils_vdf_binary_type_id__once, proton_plus_utils_vdf_binary_type_id);
	}
	return proton_plus_utils_vdf_binary_type_id__once;
}

gpointer
proton_plus_utils_vdf_binary_ref (gpointer instance)
{
	ProtonPlusUtilsVDFBinary * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
proton_plus_utils_vdf_binary_unref (gpointer instance)
{
	ProtonPlusUtilsVDFBinary * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		PROTON_PLUS_UTILS_VDF_BINARY_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

