/* wixl-heat.c generated by valac 0.36.4, the Vala compiler
 * generated from wixl-heat.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <stdio.h>
#include <gio/gio.h>
#include <libcommon.h>
#include <config.h>

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define __g_list_free__g_free0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_free0_ (var), NULL)))


extern gchar* cg;
gchar* cg = NULL;
extern gchar* dr;
gchar* dr = NULL;
extern gchar* prefix;
gchar* prefix = NULL;
extern gchar* vardir;
gchar* vardir = NULL;
extern gchar** exclude;
gchar** exclude = NULL;
extern gboolean win64;
gboolean win64 = FALSE;

gboolean filtered (const gchar* file);
gchar* escape_filename (const gchar* filename);
gint _vala_main (gchar** args, int args_length1);
static gchar** _vala_array_dup1 (gchar** self, int length);
static void _g_free0_ (gpointer var);
static void _g_list_free__g_free0_ (GList* self);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);

const GOptionEntry options[7] = {{"directory-ref", (gchar) 0, 0, G_OPTION_ARG_STRING, &dr, N_ ("Directory Ref"), NULL}, {"component-group", (gchar) 0, 0, G_OPTION_ARG_STRING, &cg, N_ ("Component Group"), NULL}, {"var", (gchar) 0, 0, G_OPTION_ARG_STRING, &vardir, N_ ("Variable for source dir"), NULL}, {"prefix", 'p', 0, G_OPTION_ARG_STRING, &prefix, N_ ("Prefix"), NULL}, {"exclude", 'x', 0, G_OPTION_ARG_STRING_ARRAY, &exclude, N_ ("Exclude prefix"), NULL}, {"win64", (gchar) 0, 0, G_OPTION_ARG_NONE, &win64, N_ ("Add Win64 Component"), NULL}, {NULL}};

gboolean filtered (const gchar* file) {
	gboolean result = FALSE;
	gchar** _tmp0_;
	gint _tmp0__length1;
	g_return_val_if_fail (file != NULL, FALSE);
	_tmp0_ = exclude;
	_tmp0__length1 = _vala_array_length (exclude);
	{
		gchar** f_collection = NULL;
		gint f_collection_length1 = 0;
		gint _f_collection_size_ = 0;
		gint f_it = 0;
		f_collection = _tmp0_;
		f_collection_length1 = _tmp0__length1;
		for (f_it = 0; f_it < _tmp0__length1; f_it = f_it + 1) {
			gchar* _tmp1_;
			gchar* f = NULL;
			_tmp1_ = g_strdup (f_collection[f_it]);
			f = _tmp1_;
			{
				const gchar* _tmp2_;
				const gchar* _tmp3_;
				gboolean _tmp4_;
				_tmp2_ = file;
				_tmp3_ = f;
				_tmp4_ = g_str_has_prefix (_tmp2_, _tmp3_);
				if (_tmp4_) {
					result = TRUE;
					_g_free0 (f);
					return result;
				}
				_g_free0 (f);
			}
		}
	}
	result = FALSE;
	return result;
}


static gchar* string_replace (const gchar* self, const gchar* old, const gchar* replacement) {
	gchar* result = NULL;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		const gchar* _tmp2_;
		_tmp2_ = old;
		_tmp1_ = (*((gchar*) _tmp2_)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp3_ = old;
		_tmp4_ = replacement;
		_tmp0_ = g_strcmp0 (_tmp3_, _tmp4_) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp5_;
		_tmp5_ = g_strdup (self);
		result = _tmp5_;
		return result;
	}
	{
		GRegex* regex = NULL;
		const gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		GRegex* _tmp9_;
		GRegex* _tmp10_;
		gchar* _tmp11_ = NULL;
		GRegex* _tmp12_;
		const gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		_tmp6_ = old;
		_tmp7_ = g_regex_escape_string (_tmp6_, -1);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_regex_new (_tmp8_, 0, 0, &_inner_error_);
		_tmp10_ = _tmp9_;
		_g_free0 (_tmp8_);
		regex = _tmp10_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		_tmp12_ = regex;
		_tmp13_ = replacement;
		_tmp14_ = g_regex_replace_literal (_tmp12_, self, (gssize) -1, 0, _tmp13_, 0, &_inner_error_);
		_tmp11_ = _tmp14_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			_g_regex_unref0 (regex);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		_tmp15_ = _tmp11_;
		_tmp11_ = NULL;
		result = _tmp15_;
		_g_free0 (_tmp11_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		g_assert_not_reached ();
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
}


gchar* escape_filename (const gchar* filename) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (filename != NULL, NULL);
	_tmp0_ = filename;
	_tmp1_ = string_replace (_tmp0_, "$", "$$");
	result = _tmp1_;
	return result;
}


static gchar* _vala_g_strjoinv (const gchar* separator, gchar** str_array, int str_array_length1) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gchar** _tmp3_;
	gint _tmp3__length1;
	_tmp0_ = separator;
	if (_tmp0_ == NULL) {
		separator = "";
	}
	_tmp3_ = str_array;
	_tmp3__length1 = str_array_length1;
	if (_tmp3_ != NULL) {
		_tmp2_ = TRUE;
	} else {
		gchar** _tmp4_;
		gint _tmp4__length1;
		_tmp4_ = str_array;
		_tmp4__length1 = str_array_length1;
		_tmp2_ = _tmp4__length1 > 0;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		gboolean _tmp5_ = FALSE;
		gchar** _tmp6_;
		gint _tmp6__length1;
		_tmp6_ = str_array;
		_tmp6__length1 = str_array_length1;
		if (_tmp6__length1 == -1) {
			gchar** _tmp7_;
			gint _tmp7__length1;
			const gchar* _tmp8_;
			_tmp7_ = str_array;
			_tmp7__length1 = str_array_length1;
			_tmp8_ = _tmp7_[0];
			_tmp5_ = _tmp8_ != NULL;
		} else {
			_tmp5_ = FALSE;
		}
		_tmp1_ = _tmp5_;
	}
	if (_tmp1_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp31_;
		gint _tmp33_;
		gint _tmp34_;
		gsize _tmp35_;
		const gchar* _tmp36_;
		gint _tmp37_;
		gint _tmp38_;
		gint _tmp39_;
		const gchar* res = NULL;
		gsize _tmp40_;
		void* _tmp41_;
		void* ptr = NULL;
		const gchar* _tmp42_;
		gchar** _tmp43_;
		gint _tmp43__length1;
		const gchar* _tmp44_;
		void* _tmp45_;
		const gchar* _tmp62_;
		len = (gsize) 1;
		{
			gboolean _tmp9_ = FALSE;
			i = 0;
			_tmp9_ = TRUE;
			while (TRUE) {
				gboolean _tmp11_ = FALSE;
				gboolean _tmp12_ = FALSE;
				gchar** _tmp13_;
				gint _tmp13__length1;
				gint _tmp21_ = 0;
				gchar** _tmp22_;
				gint _tmp22__length1;
				gint _tmp23_;
				const gchar* _tmp24_;
				gsize _tmp30_;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp13_ = str_array;
				_tmp13__length1 = str_array_length1;
				if (_tmp13__length1 != -1) {
					gint _tmp14_;
					gchar** _tmp15_;
					gint _tmp15__length1;
					_tmp14_ = i;
					_tmp15_ = str_array;
					_tmp15__length1 = str_array_length1;
					_tmp12_ = _tmp14_ < _tmp15__length1;
				} else {
					_tmp12_ = FALSE;
				}
				if (_tmp12_) {
					_tmp11_ = TRUE;
				} else {
					gboolean _tmp16_ = FALSE;
					gchar** _tmp17_;
					gint _tmp17__length1;
					_tmp17_ = str_array;
					_tmp17__length1 = str_array_length1;
					if (_tmp17__length1 == -1) {
						gchar** _tmp18_;
						gint _tmp18__length1;
						gint _tmp19_;
						const gchar* _tmp20_;
						_tmp18_ = str_array;
						_tmp18__length1 = str_array_length1;
						_tmp19_ = i;
						_tmp20_ = _tmp18_[_tmp19_];
						_tmp16_ = _tmp20_ != NULL;
					} else {
						_tmp16_ = FALSE;
					}
					_tmp11_ = _tmp16_;
				}
				if (!_tmp11_) {
					break;
				}
				_tmp22_ = str_array;
				_tmp22__length1 = str_array_length1;
				_tmp23_ = i;
				_tmp24_ = _tmp22_[_tmp23_];
				if (_tmp24_ != NULL) {
					gchar** _tmp25_;
					gint _tmp25__length1;
					gint _tmp26_;
					const gchar* _tmp27_;
					gint _tmp28_;
					gint _tmp29_;
					_tmp25_ = str_array;
					_tmp25__length1 = str_array_length1;
					_tmp26_ = i;
					_tmp27_ = _tmp25_[_tmp26_];
					_tmp28_ = strlen ((const gchar*) _tmp27_);
					_tmp29_ = _tmp28_;
					_tmp21_ = _tmp29_;
				} else {
					_tmp21_ = 0;
				}
				_tmp30_ = len;
				len = _tmp30_ + _tmp21_;
			}
		}
		_tmp31_ = i;
		if (_tmp31_ == 0) {
			gchar* _tmp32_;
			_tmp32_ = g_strdup ("");
			result = _tmp32_;
			return result;
		}
		_tmp33_ = i;
		str_array_length1 = _tmp33_;
		_tmp34_ = str_array_length1;
		_tmp35_ = len;
		_tmp36_ = separator;
		_tmp37_ = strlen ((const gchar*) _tmp36_);
		_tmp38_ = _tmp37_;
		_tmp39_ = i;
		len = _tmp35_ + (_tmp38_ * (_tmp39_ - 1));
		_tmp40_ = len;
		_tmp41_ = g_malloc (_tmp40_);
		res = _tmp41_;
		_tmp42_ = res;
		_tmp43_ = str_array;
		_tmp43__length1 = str_array_length1;
		_tmp44_ = _tmp43_[0];
		_tmp45_ = g_stpcpy ((void*) _tmp42_, (const gchar*) _tmp44_);
		ptr = _tmp45_;
		{
			gboolean _tmp46_ = FALSE;
			i = 1;
			_tmp46_ = TRUE;
			while (TRUE) {
				gint _tmp48_;
				gchar** _tmp49_;
				gint _tmp49__length1;
				void* _tmp50_;
				const gchar* _tmp51_;
				void* _tmp52_;
				const gchar* _tmp53_ = NULL;
				gchar** _tmp54_;
				gint _tmp54__length1;
				gint _tmp55_;
				const gchar* _tmp56_;
				void* _tmp60_;
				void* _tmp61_;
				if (!_tmp46_) {
					gint _tmp47_;
					_tmp47_ = i;
					i = _tmp47_ + 1;
				}
				_tmp46_ = FALSE;
				_tmp48_ = i;
				_tmp49_ = str_array;
				_tmp49__length1 = str_array_length1;
				if (!(_tmp48_ < _tmp49__length1)) {
					break;
				}
				_tmp50_ = ptr;
				_tmp51_ = separator;
				_tmp52_ = g_stpcpy (_tmp50_, (const gchar*) _tmp51_);
				ptr = _tmp52_;
				_tmp54_ = str_array;
				_tmp54__length1 = str_array_length1;
				_tmp55_ = i;
				_tmp56_ = _tmp54_[_tmp55_];
				if (_tmp56_ != NULL) {
					gchar** _tmp57_;
					gint _tmp57__length1;
					gint _tmp58_;
					const gchar* _tmp59_;
					_tmp57_ = str_array;
					_tmp57__length1 = str_array_length1;
					_tmp58_ = i;
					_tmp59_ = _tmp57_[_tmp58_];
					_tmp53_ = (const gchar*) _tmp59_;
				} else {
					_tmp53_ = "";
				}
				_tmp60_ = ptr;
				_tmp61_ = g_stpcpy (_tmp60_, _tmp53_);
				ptr = _tmp61_;
			}
		}
		_tmp62_ = res;
		res = NULL;
		result = (gchar*) _tmp62_;
		return result;
	} else {
		gchar* _tmp63_;
		_tmp63_ = g_strdup ("");
		result = _tmp63_;
		return result;
	}
}


static gchar* string_slice (const gchar* self, glong start, glong end) {
	gchar* result = NULL;
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	glong _tmp2_;
	glong _tmp5_;
	gboolean _tmp8_ = FALSE;
	glong _tmp9_;
	gboolean _tmp12_ = FALSE;
	glong _tmp13_;
	glong _tmp16_;
	glong _tmp17_;
	glong _tmp18_;
	glong _tmp19_;
	glong _tmp20_;
	gchar* _tmp21_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	_tmp2_ = start;
	if (_tmp2_ < ((glong) 0)) {
		glong _tmp3_;
		glong _tmp4_;
		_tmp3_ = string_length;
		_tmp4_ = start;
		start = _tmp3_ + _tmp4_;
	}
	_tmp5_ = end;
	if (_tmp5_ < ((glong) 0)) {
		glong _tmp6_;
		glong _tmp7_;
		_tmp6_ = string_length;
		_tmp7_ = end;
		end = _tmp6_ + _tmp7_;
	}
	_tmp9_ = start;
	if (_tmp9_ >= ((glong) 0)) {
		glong _tmp10_;
		glong _tmp11_;
		_tmp10_ = start;
		_tmp11_ = string_length;
		_tmp8_ = _tmp10_ <= _tmp11_;
	} else {
		_tmp8_ = FALSE;
	}
	g_return_val_if_fail (_tmp8_, NULL);
	_tmp13_ = end;
	if (_tmp13_ >= ((glong) 0)) {
		glong _tmp14_;
		glong _tmp15_;
		_tmp14_ = end;
		_tmp15_ = string_length;
		_tmp12_ = _tmp14_ <= _tmp15_;
	} else {
		_tmp12_ = FALSE;
	}
	g_return_val_if_fail (_tmp12_, NULL);
	_tmp16_ = start;
	_tmp17_ = end;
	g_return_val_if_fail (_tmp16_ <= _tmp17_, NULL);
	_tmp18_ = start;
	_tmp19_ = end;
	_tmp20_ = start;
	_tmp21_ = g_strndup (((gchar*) self) + _tmp18_, (gsize) (_tmp19_ - _tmp20_));
	result = _tmp21_;
	return result;
}


static gchar** _vala_array_dup1 (gchar** self, int length) {
	gchar** result;
	int i;
	result = g_new0 (gchar*, length + 1);
	for (i = 0; i < length; i++) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


static void _g_free0_ (gpointer var) {
	var = (g_free (var), NULL);
}


static void _g_list_free__g_free0_ (GList* self) {
	g_list_foreach (self, (GFunc) _g_free0_, NULL);
	g_list_free (self);
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	gchar* cmdline = NULL;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar* _tmp1_;
	GOptionContext* opt_context = NULL;
	GOptionContext* _tmp2_;
	GOptionContext* _tmp3_;
	GOptionContext* _tmp4_;
	gchar* _tmp5_;
	gchar* sourcedir = NULL;
	gchar* _tmp6_;
	const gchar* _tmp16_;
	const gchar* _tmp18_;
	FILE* _tmp21_;
	FILE* _tmp22_;
	FILE* _tmp23_;
	FILE* _tmp24_;
	const gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar** last_path = NULL;
	gint last_path_length1;
	gint _last_path_size_;
	GList* cmpref = NULL;
	gchar* indent = NULL;
	gchar* _tmp28_;
	const gchar* _tmp155_;
	gchar* _tmp156_;
	gchar** _tmp157_;
	gint _tmp157__length1;
	FILE* _tmp165_;
	FILE* _tmp166_;
	const gchar* _tmp167_;
	FILE* _tmp181_;
	FILE* _tmp182_;
	FILE* _tmp183_;
	const gchar* _tmp184_;
	gchar* _tmp185_;
	gchar* _tmp186_;
	GError * _inner_error_ = NULL;
	_tmp0_ = args;
	_tmp0__length1 = args_length1;
	_tmp1_ = _vala_g_strjoinv (" ", _tmp0_, _tmp0__length1);
	cmdline = _tmp1_;
	_tmp2_ = g_option_context_new ("");
	opt_context = _tmp2_;
	_tmp3_ = opt_context;
	g_option_context_set_help_enabled (_tmp3_, TRUE);
	_tmp4_ = opt_context;
	g_option_context_add_main_entries (_tmp4_, options, NULL);
	_tmp5_ = g_strdup ("TARGETDIR");
	_g_free0 (dr);
	dr = _tmp5_;
	_tmp6_ = g_strdup ("SourceDir");
	sourcedir = _tmp6_;
	{
		GOptionContext* _tmp7_;
		_tmp7_ = opt_context;
		g_option_context_parse (_tmp7_, &args_length1, &args, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			gint _tmp8_ = 0;
			if (g_error_matches (_inner_error_, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE)) {
				goto __catch1_g_option_error_bad_value;
			}
			if (_inner_error_->domain == G_OPTION_ERROR) {
				goto __catch1_g_option_error;
			}
			_g_free0 (sourcedir);
			_g_option_context_free0 (opt_context);
			_g_free0 (cmdline);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return _tmp8_;
		}
	}
	goto __finally1;
	__catch1_g_option_error_bad_value:
	{
		GError* err = NULL;
		FILE* _tmp9_;
		GOptionContext* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp9_ = stdout;
		_tmp10_ = opt_context;
		_tmp11_ = g_option_context_get_help (_tmp10_, TRUE, NULL);
		_tmp12_ = _tmp11_;
		fprintf (_tmp9_, "%s", _tmp12_);
		_g_free0 (_tmp12_);
		result = 1;
		_g_error_free0 (err);
		_g_free0 (sourcedir);
		_g_option_context_free0 (opt_context);
		_g_free0 (cmdline);
		return result;
	}
	goto __finally1;
	__catch1_g_option_error:
	{
		GError* _error_ = NULL;
		GError* _tmp13_;
		const gchar* _tmp14_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp13_ = _error_;
		_tmp14_ = _tmp13_->message;
		g_warning ("wixl-heat.vala:50: %s", _tmp14_);
		_g_error_free0 (_error_);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		gint _tmp15_ = 0;
		_g_free0 (sourcedir);
		_g_option_context_free0 (opt_context);
		_g_free0 (cmdline);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return _tmp15_;
	}
	_tmp16_ = prefix;
	if (_tmp16_ == NULL) {
		FILE* _tmp17_;
		_tmp17_ = stderr;
		fprintf (_tmp17_, "Please specify source dir prefix\n");
		result = 1;
		_g_free0 (sourcedir);
		_g_option_context_free0 (opt_context);
		_g_free0 (cmdline);
		return result;
	}
	_tmp18_ = vardir;
	if (_tmp18_ != NULL) {
		const gchar* _tmp19_;
		gchar* _tmp20_;
		_tmp19_ = vardir;
		_tmp20_ = g_strdup_printf ("$(%s)", _tmp19_);
		_g_free0 (sourcedir);
		sourcedir = _tmp20_;
	}
	_tmp21_ = stdout;
	fprintf (_tmp21_, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
	_tmp22_ = stdout;
	fprintf (_tmp22_, "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\n");
	_tmp23_ = stdout;
	fprintf (_tmp23_, "  <Fragment>\n");
	_tmp24_ = stdout;
	_tmp25_ = dr;
	_tmp26_ = g_strdup_printf ("    <DirectoryRef Id=\"%s\">\n", _tmp25_);
	_tmp27_ = _tmp26_;
	fprintf (_tmp24_, "%s", _tmp27_);
	_g_free0 (_tmp27_);
	last_path = NULL;
	last_path_length1 = 0;
	_last_path_size_ = last_path_length1;
	cmpref = NULL;
	_tmp28_ = g_strdup ("      ");
	indent = _tmp28_;
	{
		GDataInputStream* dis = NULL;
		WixlUnixInputStream* _tmp29_;
		WixlUnixInputStream* _tmp30_;
		GDataInputStream* _tmp31_;
		GDataInputStream* _tmp32_;
		gchar* line = NULL;
		_tmp29_ = wixl_unix_input_stream_new (0);
		_tmp30_ = _tmp29_;
		_tmp31_ = g_data_input_stream_new ((GInputStream*) _tmp30_);
		_tmp32_ = _tmp31_;
		_g_object_unref0 (_tmp30_);
		dis = _tmp32_;
		while (TRUE) {
			gchar* _tmp33_ = NULL;
			GDataInputStream* _tmp34_;
			gchar* _tmp35_;
			gchar* _tmp36_;
			const gchar* _tmp37_;
			const gchar* _tmp38_;
			const gchar* _tmp39_;
			gboolean _tmp40_;
			gchar* file = NULL;
			const gchar* _tmp41_;
			const gchar* _tmp42_;
			gint _tmp43_;
			gint _tmp44_;
			const gchar* _tmp45_;
			gint _tmp46_;
			gint _tmp47_;
			gchar* _tmp48_;
			const gchar* _tmp49_;
			gboolean _tmp50_;
			GFile* gfile = NULL;
			const gchar* _tmp51_;
			GFile* _tmp52_;
			gboolean is_directory = FALSE;
			GFile* _tmp53_;
			GFileType _tmp54_;
			gchar* _tmp55_ = NULL;
			gboolean _tmp56_;
			gchar* dir = NULL;
			gchar* _tmp61_;
			gchar** path = NULL;
			const gchar* _tmp62_;
			gchar** _tmp63_;
			gchar** _tmp64_;
			gint path_length1;
			gint _path_size_;
			gint i = 0;
			gchar** _tmp65_;
			gint _tmp65__length1;
			gchar** _tmp109_;
			gint _tmp109__length1;
			gchar** _tmp110_;
			gint _tmp110__length1;
			gboolean _tmp111_;
			_tmp34_ = dis;
			_tmp35_ = g_data_input_stream_read_line (_tmp34_, NULL, NULL, &_inner_error_);
			_tmp33_ = _tmp35_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				_g_free0 (line);
				_g_object_unref0 (dis);
				goto __catch2_g_error;
			}
			_tmp36_ = _tmp33_;
			_tmp33_ = NULL;
			_g_free0 (line);
			line = _tmp36_;
			_tmp37_ = line;
			if (!(_tmp37_ != NULL)) {
				_g_free0 (_tmp33_);
				break;
			}
			_tmp38_ = line;
			_tmp39_ = prefix;
			_tmp40_ = g_str_has_prefix (_tmp38_, _tmp39_);
			if (!_tmp40_) {
				_g_free0 (_tmp33_);
				continue;
			}
			_tmp41_ = line;
			_tmp42_ = prefix;
			_tmp43_ = strlen (_tmp42_);
			_tmp44_ = _tmp43_;
			_tmp45_ = line;
			_tmp46_ = strlen (_tmp45_);
			_tmp47_ = _tmp46_;
			_tmp48_ = string_slice (_tmp41_, (glong) _tmp44_, (glong) _tmp47_);
			file = _tmp48_;
			_tmp49_ = file;
			_tmp50_ = filtered (_tmp49_);
			if (_tmp50_) {
				_g_free0 (file);
				_g_free0 (_tmp33_);
				continue;
			}
			_tmp51_ = line;
			_tmp52_ = g_file_new_for_path (_tmp51_);
			gfile = _tmp52_;
			_tmp53_ = gfile;
			_tmp54_ = g_file_query_file_type (_tmp53_, G_FILE_QUERY_INFO_NONE, NULL);
			is_directory = _tmp54_ == G_FILE_TYPE_DIRECTORY;
			_tmp56_ = is_directory;
			if (_tmp56_) {
				const gchar* _tmp57_;
				gchar* _tmp58_;
				_tmp57_ = file;
				_tmp58_ = g_strdup (_tmp57_);
				_g_free0 (_tmp55_);
				_tmp55_ = _tmp58_;
			} else {
				const gchar* _tmp59_;
				gchar* _tmp60_;
				_tmp59_ = file;
				_tmp60_ = g_path_get_dirname (_tmp59_);
				_g_free0 (_tmp55_);
				_tmp55_ = _tmp60_;
			}
			_tmp61_ = g_strdup (_tmp55_);
			dir = _tmp61_;
			_tmp62_ = dir;
			_tmp64_ = _tmp63_ = g_strsplit (_tmp62_, G_DIR_SEPARATOR_S, -1);
			path = _tmp64_;
			path_length1 = _vala_array_length (_tmp63_);
			_path_size_ = path_length1;
			i = 0;
			_tmp65_ = last_path;
			_tmp65__length1 = last_path_length1;
			if (_tmp65_ != NULL) {
				while (TRUE) {
					gboolean _tmp66_ = FALSE;
					gboolean _tmp67_ = FALSE;
					gchar** _tmp68_;
					gint _tmp68__length1;
					gint _tmp69_;
					const gchar* _tmp70_;
					gint _tmp80_;
					_tmp68_ = path;
					_tmp68__length1 = path_length1;
					_tmp69_ = i;
					_tmp70_ = _tmp68_[_tmp69_];
					if (_tmp70_ != NULL) {
						gchar** _tmp71_;
						gint _tmp71__length1;
						gint _tmp72_;
						const gchar* _tmp73_;
						_tmp71_ = last_path;
						_tmp71__length1 = last_path_length1;
						_tmp72_ = i;
						_tmp73_ = _tmp71_[_tmp72_];
						_tmp67_ = _tmp73_ != NULL;
					} else {
						_tmp67_ = FALSE;
					}
					if (_tmp67_) {
						gchar** _tmp74_;
						gint _tmp74__length1;
						gint _tmp75_;
						const gchar* _tmp76_;
						gchar** _tmp77_;
						gint _tmp77__length1;
						gint _tmp78_;
						const gchar* _tmp79_;
						_tmp74_ = path;
						_tmp74__length1 = path_length1;
						_tmp75_ = i;
						_tmp76_ = _tmp74_[_tmp75_];
						_tmp77_ = last_path;
						_tmp77__length1 = last_path_length1;
						_tmp78_ = i;
						_tmp79_ = _tmp77_[_tmp78_];
						_tmp66_ = g_strcmp0 (_tmp76_, _tmp79_) == 0;
					} else {
						_tmp66_ = FALSE;
					}
					if (!_tmp66_) {
						break;
					}
					_tmp80_ = i;
					i = _tmp80_ + 1;
				}
				{
					gint j = 0;
					gchar** _tmp81_;
					gint _tmp81__length1;
					gint _tmp82_;
					_tmp81_ = last_path;
					_tmp81__length1 = last_path_length1;
					_tmp82_ = i;
					j = _tmp81__length1 - _tmp82_;
					{
						gboolean _tmp83_ = FALSE;
						_tmp83_ = TRUE;
						while (TRUE) {
							gint _tmp85_;
							const gchar* _tmp86_;
							gchar* _tmp87_;
							FILE* _tmp88_;
							const gchar* _tmp89_;
							gchar* _tmp90_;
							gchar* _tmp91_;
							if (!_tmp83_) {
								gint _tmp84_;
								_tmp84_ = j;
								j = _tmp84_ - 1;
							}
							_tmp83_ = FALSE;
							_tmp85_ = j;
							if (!(_tmp85_ > 0)) {
								break;
							}
							_tmp86_ = indent;
							_tmp87_ = string_slice (_tmp86_, (glong) 0, (glong) -2);
							_g_free0 (indent);
							indent = _tmp87_;
							_tmp88_ = stdout;
							_tmp89_ = indent;
							_tmp90_ = g_strconcat (_tmp89_, "</Directory>\n", NULL);
							_tmp91_ = _tmp90_;
							fprintf (_tmp88_, "%s", _tmp91_);
							_g_free0 (_tmp91_);
						}
					}
				}
			}
			{
				gboolean _tmp92_ = FALSE;
				_tmp92_ = TRUE;
				while (TRUE) {
					gint _tmp94_;
					gchar** _tmp95_;
					gint _tmp95__length1;
					FILE* _tmp96_;
					const gchar* _tmp97_;
					gchar* _tmp98_;
					gchar* _tmp99_;
					gchar** _tmp100_;
					gint _tmp100__length1;
					gint _tmp101_;
					const gchar* _tmp102_;
					gchar* _tmp103_;
					gchar* _tmp104_;
					gchar* _tmp105_;
					gchar* _tmp106_;
					const gchar* _tmp107_;
					gchar* _tmp108_;
					if (!_tmp92_) {
						gint _tmp93_;
						_tmp93_ = i;
						i = _tmp93_ + 1;
					}
					_tmp92_ = FALSE;
					_tmp94_ = i;
					_tmp95_ = path;
					_tmp95__length1 = path_length1;
					if (!(_tmp94_ < _tmp95__length1)) {
						break;
					}
					_tmp96_ = stdout;
					_tmp97_ = indent;
					_tmp98_ = wixl_random_id ("dir");
					_tmp99_ = _tmp98_;
					_tmp100_ = path;
					_tmp100__length1 = path_length1;
					_tmp101_ = i;
					_tmp102_ = _tmp100_[_tmp101_];
					_tmp103_ = g_strdup_printf ("<Directory Id=\"%s\" Name=\"%s\">\n", _tmp99_, _tmp102_);
					_tmp104_ = _tmp103_;
					_tmp105_ = g_strconcat (_tmp97_, _tmp104_, NULL);
					_tmp106_ = _tmp105_;
					fprintf (_tmp96_, "%s", _tmp106_);
					_g_free0 (_tmp106_);
					_g_free0 (_tmp104_);
					_g_free0 (_tmp99_);
					_tmp107_ = indent;
					_tmp108_ = g_strconcat (_tmp107_, "  ", NULL);
					_g_free0 (indent);
					indent = _tmp108_;
				}
			}
			_tmp109_ = path;
			_tmp109__length1 = path_length1;
			_tmp110_ = (_tmp109_ != NULL) ? _vala_array_dup1 (_tmp109_, _tmp109__length1) : ((gpointer) _tmp109_);
			_tmp110__length1 = _tmp109__length1;
			last_path = (_vala_array_free (last_path, last_path_length1, (GDestroyNotify) g_free), NULL);
			last_path = _tmp110_;
			last_path_length1 = _tmp110__length1;
			_last_path_size_ = last_path_length1;
			_tmp111_ = is_directory;
			if (!_tmp111_) {
				gchar* id = NULL;
				const gchar* _tmp112_;
				gchar* _tmp113_;
				const gchar* _tmp114_;
				gchar* _tmp115_;
				gboolean _tmp116_;
				const gchar* _tmp131_;
				gchar* _tmp132_;
				gchar* _tmp133_;
				const gchar* _tmp134_;
				gchar* _tmp135_;
				gchar* _tmp136_;
				gchar* _tmp137_;
				FILE* _tmp138_;
				const gchar* _tmp139_;
				const gchar* _tmp140_;
				gchar* _tmp141_;
				gchar* _tmp142_;
				const gchar* _tmp143_;
				gchar* _tmp144_;
				gchar* _tmp145_;
				gchar* _tmp146_;
				gchar* _tmp147_;
				FILE* _tmp148_;
				const gchar* _tmp149_;
				gchar* _tmp150_;
				gchar* _tmp151_;
				_tmp112_ = file;
				_tmp113_ = wixl_generate_id ("cmp", (guint) 1, _tmp112_, NULL);
				id = _tmp113_;
				_tmp114_ = id;
				_tmp115_ = g_strdup (_tmp114_);
				cmpref = g_list_append (cmpref, _tmp115_);
				_tmp116_ = win64;
				if (_tmp116_) {
					FILE* _tmp117_;
					const gchar* _tmp118_;
					const gchar* _tmp119_;
					gchar* _tmp120_;
					gchar* _tmp121_;
					gchar* _tmp122_;
					gchar* _tmp123_;
					_tmp117_ = stdout;
					_tmp118_ = indent;
					_tmp119_ = id;
					_tmp120_ = g_strdup_printf ("<Component Win64=\"$(var.Win64)\" Id=\"%s\" Guid=\"*\">\n", _tmp119_);
					_tmp121_ = _tmp120_;
					_tmp122_ = g_strconcat (_tmp118_, _tmp121_, NULL);
					_tmp123_ = _tmp122_;
					fprintf (_tmp117_, "%s", _tmp123_);
					_g_free0 (_tmp123_);
					_g_free0 (_tmp121_);
				} else {
					FILE* _tmp124_;
					const gchar* _tmp125_;
					const gchar* _tmp126_;
					gchar* _tmp127_;
					gchar* _tmp128_;
					gchar* _tmp129_;
					gchar* _tmp130_;
					_tmp124_ = stdout;
					_tmp125_ = indent;
					_tmp126_ = id;
					_tmp127_ = g_strdup_printf ("<Component Id=\"%s\" Guid=\"*\">\n", _tmp126_);
					_tmp128_ = _tmp127_;
					_tmp129_ = g_strconcat (_tmp125_, _tmp128_, NULL);
					_tmp130_ = _tmp129_;
					fprintf (_tmp124_, "%s", _tmp130_);
					_g_free0 (_tmp130_);
					_g_free0 (_tmp128_);
				}
				_tmp131_ = sourcedir;
				_tmp132_ = g_strconcat (_tmp131_, G_DIR_SEPARATOR_S, NULL);
				_tmp133_ = _tmp132_;
				_tmp134_ = file;
				_tmp135_ = escape_filename (_tmp134_);
				_tmp136_ = _tmp135_;
				_tmp137_ = g_strconcat (_tmp133_, _tmp136_, NULL);
				_g_free0 (file);
				file = _tmp137_;
				_g_free0 (_tmp136_);
				_g_free0 (_tmp133_);
				_tmp138_ = stdout;
				_tmp139_ = indent;
				_tmp140_ = file;
				_tmp141_ = wixl_generate_id ("fil", (guint) 1, _tmp140_, NULL);
				_tmp142_ = _tmp141_;
				_tmp143_ = file;
				_tmp144_ = g_strdup_printf ("  <File Id=\"%s\" KeyPath=\"yes\" Source=\"%s\"/>\n", _tmp142_, _tmp143_);
				_tmp145_ = _tmp144_;
				_tmp146_ = g_strconcat (_tmp139_, _tmp145_, NULL);
				_tmp147_ = _tmp146_;
				fprintf (_tmp138_, "%s", _tmp147_);
				_g_free0 (_tmp147_);
				_g_free0 (_tmp145_);
				_g_free0 (_tmp142_);
				_tmp148_ = stdout;
				_tmp149_ = indent;
				_tmp150_ = g_strconcat (_tmp149_, "</Component>\n", NULL);
				_tmp151_ = _tmp150_;
				fprintf (_tmp148_, "%s", _tmp151_);
				_g_free0 (_tmp151_);
				_g_free0 (id);
			}
			path = (_vala_array_free (path, path_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (dir);
			_g_free0 (_tmp55_);
			_g_object_unref0 (gfile);
			_g_free0 (file);
			_g_free0 (_tmp33_);
		}
		_g_free0 (line);
		_g_object_unref0 (dis);
	}
	goto __finally2;
	__catch2_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp152_;
		const gchar* _tmp153_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp152_ = _error_;
		_tmp153_ = _tmp152_->message;
		g_warning ("wixl-heat.vala:115: %s", _tmp153_);
		_g_error_free0 (_error_);
	}
	__finally2:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		gint _tmp154_ = 0;
		_g_free0 (indent);
		__g_list_free__g_free0_0 (cmpref);
		last_path = (_vala_array_free (last_path, last_path_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (sourcedir);
		_g_option_context_free0 (opt_context);
		_g_free0 (cmdline);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return _tmp154_;
	}
	_tmp155_ = indent;
	_tmp156_ = string_slice (_tmp155_, (glong) 0, (glong) -2);
	_g_free0 (indent);
	indent = _tmp156_;
	_tmp157_ = last_path;
	_tmp157__length1 = last_path_length1;
	{
		gchar** l_collection = NULL;
		gint l_collection_length1 = 0;
		gint _l_collection_size_ = 0;
		gint l_it = 0;
		l_collection = _tmp157_;
		l_collection_length1 = _tmp157__length1;
		for (l_it = 0; l_it < _tmp157__length1; l_it = l_it + 1) {
			gchar* _tmp158_;
			gchar* l = NULL;
			_tmp158_ = g_strdup (l_collection[l_it]);
			l = _tmp158_;
			{
				FILE* _tmp159_;
				const gchar* _tmp160_;
				gchar* _tmp161_;
				gchar* _tmp162_;
				const gchar* _tmp163_;
				gchar* _tmp164_;
				_tmp159_ = stdout;
				_tmp160_ = indent;
				_tmp161_ = g_strconcat (_tmp160_, "</Directory>\n", NULL);
				_tmp162_ = _tmp161_;
				fprintf (_tmp159_, "%s", _tmp162_);
				_g_free0 (_tmp162_);
				_tmp163_ = indent;
				_tmp164_ = string_slice (_tmp163_, (glong) 0, (glong) -2);
				_g_free0 (indent);
				indent = _tmp164_;
				_g_free0 (l);
			}
		}
	}
	_tmp165_ = stdout;
	fprintf (_tmp165_, "    </DirectoryRef>\n");
	_tmp166_ = stdout;
	fprintf (_tmp166_, "  </Fragment>\n");
	_tmp167_ = cg;
	if (_tmp167_ != NULL) {
		FILE* _tmp168_;
		FILE* _tmp169_;
		const gchar* _tmp170_;
		gchar* _tmp171_;
		gchar* _tmp172_;
		GList* _tmp173_;
		FILE* _tmp179_;
		FILE* _tmp180_;
		_tmp168_ = stdout;
		fprintf (_tmp168_, "  <Fragment>\n");
		_tmp169_ = stdout;
		_tmp170_ = cg;
		_tmp171_ = g_strdup_printf ("    <ComponentGroup Id=\"%s\">\n", _tmp170_);
		_tmp172_ = _tmp171_;
		fprintf (_tmp169_, "%s", _tmp172_);
		_g_free0 (_tmp172_);
		_tmp173_ = cmpref;
		{
			GList* id_collection = NULL;
			GList* id_it = NULL;
			id_collection = _tmp173_;
			for (id_it = id_collection; id_it != NULL; id_it = id_it->next) {
				gchar* _tmp174_;
				gchar* id = NULL;
				_tmp174_ = g_strdup ((const gchar*) id_it->data);
				id = _tmp174_;
				{
					FILE* _tmp175_;
					const gchar* _tmp176_;
					gchar* _tmp177_;
					gchar* _tmp178_;
					_tmp175_ = stdout;
					_tmp176_ = id;
					_tmp177_ = g_strdup_printf ("      <ComponentRef Id=\"%s\"/>\n", _tmp176_);
					_tmp178_ = _tmp177_;
					fprintf (_tmp175_, "%s", _tmp178_);
					_g_free0 (_tmp178_);
					_g_free0 (id);
				}
			}
		}
		_tmp179_ = stdout;
		fprintf (_tmp179_, "    </ComponentGroup>\n");
		_tmp180_ = stdout;
		fprintf (_tmp180_, "  </Fragment>\n");
	}
	_tmp181_ = stdout;
	fprintf (_tmp181_, "</Wix>\n");
	_tmp182_ = stdout;
	fprintf (_tmp182_, "<!-- generated with %s -->\n", PACKAGE_STRING);
	_tmp183_ = stdout;
	_tmp184_ = cmdline;
	_tmp185_ = string_replace (_tmp184_, "--", "-");
	_tmp186_ = _tmp185_;
	fprintf (_tmp183_, "<!-- %s -->\n", _tmp186_);
	_g_free0 (_tmp186_);
	result = 0;
	_g_free0 (indent);
	__g_list_free__g_free0_0 (cmpref);
	last_path = (_vala_array_free (last_path, last_path_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (sourcedir);
	_g_option_context_free0 (opt_context);
	_g_free0 (cmdline);
	return result;
}


int main (int argc, char ** argv) {
#if !GLIB_CHECK_VERSION (2,35,0)
	g_type_init ();
#endif
	return _vala_main (argv, argc);
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


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



