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

/* SPDX-License-Identifier: GPL-3.0-or-later*/

#include <glib.h>
#include <float.h>
#include <math.h>
#include "graphs.h"
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <glib-object.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 struct _GraphsXryColumn GraphsXryColumn;
#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))
enum  {
	GRAPHS_XRY_PARSER_0_PROPERTY,
	GRAPHS_XRY_PARSER_NUM_PROPERTIES
};
static GParamSpec* graphs_xry_parser_properties[GRAPHS_XRY_PARSER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _graphs_xry_column_free0(var) ((var == NULL) ? NULL : (var = (graphs_xry_column_free (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))

struct _GraphsXryColumn {
	gdouble* data;
	gint data_length1;
	gint _data_size_;
	gint* first_val;
	gint last_val;
};

struct _GraphsXryParserPrivate {
	GDataInputStream* input;
	GraphsXryColumn** columns;
	gint columns_length1;
	gint _columns_size_;
	gdouble* xdata;
	gint xdata_length1;
	gint _xdata_size_;
};

static gint GraphsXryParser_private_offset;
static gpointer graphs_xry_parser_parent_class = NULL;

VALA_EXTERN void graphs_xry_column_free (GraphsXryColumn * self);
static void graphs_xry_column_instance_init (GraphsXryColumn * self);
VALA_EXTERN GraphsXryColumn* graphs_xry_column_new (gint size);
static void graphs_xry_parser_skip (GraphsXryParser* self,
                             gint n,
                             GError** error);
static gint* _int_dup (gint* self);
static gboolean _int_equal (const gint * s1,
                     const gint * s2);
static gdouble* _vala_array_dup8 (gdouble* self,
                           gssize length);
static gdouble* _vala_array_dup9 (gdouble* self,
                           gssize length);
static void graphs_xry_parser_finalize (GObject * obj);
static GType graphs_xry_parser_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);

GraphsXryColumn*
graphs_xry_column_new (gint size)
{
	GraphsXryColumn* self;
	gdouble* _tmp0_;
	self = g_slice_new0 (GraphsXryColumn);
	graphs_xry_column_instance_init (self);
	_tmp0_ = g_new0 (gdouble, size);
	self->data = (g_free (self->data), NULL);
	self->data = _tmp0_;
	self->data_length1 = size;
	self->_data_size_ = self->data_length1;
	return self;
}

static void
graphs_xry_column_instance_init (GraphsXryColumn * self)
{
	self->first_val = NULL;
	self->last_val = 0;
}

void
graphs_xry_column_free (GraphsXryColumn * self)
{
	self->data = (g_free (self->data), NULL);
	_g_free0 (self->first_val);
	g_slice_free (GraphsXryColumn, self);
}

static inline gpointer
graphs_xry_parser_get_instance_private (GraphsXryParser* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsXryParser_private_offset);
}

static void
graphs_xry_parser_skip (GraphsXryParser* self,
                        gint n,
                        GError** error)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GDataInputStream* _tmp2_;
				gchar* _tmp3_;
				gchar* _tmp4_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(i < n)) {
					break;
				}
				_tmp2_ = self->priv->input;
				_tmp3_ = g_data_input_stream_read_line (_tmp2_, NULL, NULL, &_inner_error0_);
				_tmp4_ = _tmp3_;
				_g_free0 (_tmp4_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					return;
				}
			}
		}
	}
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static gint*
_int_dup (gint* self)
{
	gint* dup;
	dup = g_new0 (gint, 1);
	memcpy (dup, self, sizeof (gint));
	return dup;
}

static gpointer
__int_dup0 (gpointer self)
{
	return self ? _int_dup (self) : NULL;
}

static gboolean
_int_equal (const gint * s1,
            const gint * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	return (*s1) == (*s2);
}

static gdouble*
_vala_array_dup8 (gdouble* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gdouble));
	}
	return NULL;
}

static gdouble*
_vala_array_dup9 (gdouble* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gdouble));
	}
	return NULL;
}

static gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

void
graphs_xry_parser_parse (GraphsXryParser* self,
                         GraphsData* data,
                         GraphsImportSettings* settings,
                         GraphsItemList* items,
                         GError** error)
{
	GCharsetConverter* converter = NULL;
	GCharsetConverter* _tmp0_;
	GFileInputStream* _tmp1_ = NULL;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GFileInputStream* _tmp4_;
	GConverterInputStream* conv_stream = NULL;
	GCharsetConverter* _tmp5_;
	GConverterInputStream* _tmp6_;
	GConverterInputStream* _tmp7_;
	GDataInputStream* _tmp8_;
	gchar* _tmp9_ = NULL;
	GDataInputStream* _tmp10_;
	gchar* _tmp11_;
	gchar** b_params = NULL;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar** _tmp14_;
	gchar** _tmp15_;
	gchar** _tmp16_;
	gint _tmp16__length1;
	gint b_params_length1;
	gint _b_params_size_;
	gdouble x_step = 0.0;
	gchar** _tmp17_;
	gint _tmp17__length1;
	const gchar* _tmp18_;
	gdouble x_value = 0.0;
	gchar** _tmp19_;
	gint _tmp19__length1;
	const gchar* _tmp20_;
	gchar* _tmp21_ = NULL;
	GDataInputStream* _tmp22_;
	gchar* _tmp23_;
	gchar** info = NULL;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar** _tmp26_;
	gchar** _tmp27_;
	gchar** _tmp28_;
	gint _tmp28__length1;
	gint info_length1;
	gint _info_size_;
	gdouble _tmp29_ = 0.0;
	gchar** _tmp30_;
	gint _tmp30__length1;
	const gchar* _tmp31_;
	gint item_count = 0;
	gdouble _tmp32_ = 0.0;
	gchar** _tmp33_;
	gint _tmp33__length1;
	const gchar* _tmp34_;
	gint length = 0;
	GraphsXryColumn** _tmp35_;
	gdouble* _tmp40_;
	GRegex* whitespace = NULL;
	GRegex* _tmp41_;
	gchar* _tmp118_ = NULL;
	GDataInputStream* _tmp119_;
	gchar* _tmp120_;
	gdouble _tmp121_ = 0.0;
	gint text_item_count = 0;
	GDataInputStream* _tmp144_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (data != NULL);
	g_return_if_fail (settings != NULL);
	g_return_if_fail (items != NULL);
	_tmp0_ = g_charset_converter_new ("UTF-8", "ISO-8859-1", &_inner_error0_);
	converter = _tmp0_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp2_ = graphs_import_settings_get_file (settings);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_file_read (_tmp3_, NULL, &_inner_error0_);
	_tmp1_ = _tmp4_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (converter);
		return;
	}
	_tmp5_ = converter;
	_tmp6_ = (GConverterInputStream*) g_converter_input_stream_new ((GInputStream*) _tmp1_, (GConverter*) _tmp5_);
	conv_stream = _tmp6_;
	_tmp7_ = conv_stream;
	_tmp8_ = g_data_input_stream_new ((GInputStream*) _tmp7_);
	_g_object_unref0 (self->priv->input);
	self->priv->input = _tmp8_;
	graphs_xry_parser_skip (self, 4, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	_tmp10_ = self->priv->input;
	_tmp11_ = g_data_input_stream_read_line (_tmp10_, NULL, NULL, &_inner_error0_);
	_tmp9_ = _tmp11_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	_tmp12_ = string_strip (_tmp9_);
	_tmp13_ = _tmp12_;
	_tmp15_ = _tmp14_ = g_strsplit (_tmp13_, " ", 0);
	_tmp16_ = _tmp15_;
	_tmp16__length1 = _vala_array_length (_tmp14_);
	_g_free0 (_tmp13_);
	b_params = _tmp16_;
	b_params_length1 = _tmp16__length1;
	_b_params_size_ = b_params_length1;
	_tmp17_ = b_params;
	_tmp17__length1 = b_params_length1;
	_tmp18_ = _tmp17_[3];
	x_step = graphs_evaluate_string (_tmp18_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp9_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	_tmp19_ = b_params;
	_tmp19__length1 = b_params_length1;
	_tmp20_ = _tmp19_[0];
	x_value = graphs_evaluate_string (_tmp20_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp9_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	graphs_xry_parser_skip (self, 12, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp9_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	_tmp22_ = self->priv->input;
	_tmp23_ = g_data_input_stream_read_line (_tmp22_, NULL, NULL, &_inner_error0_);
	_tmp21_ = _tmp23_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp9_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	_tmp24_ = string_strip (_tmp21_);
	_tmp25_ = _tmp24_;
	_tmp27_ = _tmp26_ = g_strsplit (_tmp25_, " ", 0);
	_tmp28_ = _tmp27_;
	_tmp28__length1 = _vala_array_length (_tmp26_);
	_g_free0 (_tmp25_);
	info = _tmp28_;
	info_length1 = _tmp28__length1;
	_info_size_ = info_length1;
	_tmp30_ = info;
	_tmp30__length1 = info_length1;
	_tmp31_ = _tmp30_[0];
	_tmp29_ = graphs_evaluate_string (_tmp31_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp21_);
		b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp9_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	item_count = (gint) _tmp29_;
	_tmp33_ = info;
	_tmp33__length1 = info_length1;
	_tmp34_ = _tmp33_[1];
	_tmp32_ = graphs_evaluate_string (_tmp34_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp21_);
		b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp9_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	length = (gint) _tmp32_;
	_tmp35_ = g_new0 (GraphsXryColumn*, item_count + 1);
	self->priv->columns = (_vala_array_free (self->priv->columns, self->priv->columns_length1, (GDestroyNotify) graphs_xry_column_free), NULL);
	self->priv->columns = _tmp35_;
	self->priv->columns_length1 = item_count;
	self->priv->_columns_size_ = self->priv->columns_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp36_ = FALSE;
			_tmp36_ = TRUE;
			while (TRUE) {
				GraphsXryColumn** _tmp38_;
				gint _tmp38__length1;
				GraphsXryColumn* _tmp39_;
				if (!_tmp36_) {
					gint _tmp37_;
					_tmp37_ = i;
					i = _tmp37_ + 1;
				}
				_tmp36_ = FALSE;
				if (!(i < item_count)) {
					break;
				}
				_tmp38_ = self->priv->columns;
				_tmp38__length1 = self->priv->columns_length1;
				_tmp39_ = graphs_xry_column_new (length);
				_graphs_xry_column_free0 (_tmp38_[i]);
				_tmp38_[i] = _tmp39_;
			}
		}
	}
	_tmp40_ = g_new0 (gdouble, length);
	self->priv->xdata = (g_free (self->priv->xdata), NULL);
	self->priv->xdata = _tmp40_;
	self->priv->xdata_length1 = length;
	self->priv->_xdata_size_ = self->priv->xdata_length1;
	_tmp41_ = g_regex_new ("\\s+", 0, 0, &_inner_error0_);
	whitespace = _tmp41_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp21_);
		b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp9_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp42_ = FALSE;
			_tmp42_ = TRUE;
			while (TRUE) {
				gchar* _tmp44_ = NULL;
				GDataInputStream* _tmp45_;
				gchar* _tmp46_;
				gchar* line = NULL;
				gchar* _tmp47_;
				gchar** values = NULL;
				GRegex* _tmp48_;
				const gchar* _tmp49_;
				gchar** _tmp50_;
				gchar** _tmp51_;
				gint values_length1;
				gint _values_size_;
				gdouble* _tmp73_;
				gint _tmp73__length1;
				if (!_tmp42_) {
					gint _tmp43_;
					_tmp43_ = i;
					i = _tmp43_ + 1;
				}
				_tmp42_ = FALSE;
				if (!(i < length)) {
					break;
				}
				_tmp45_ = self->priv->input;
				_tmp46_ = g_data_input_stream_read_line (_tmp45_, NULL, NULL, &_inner_error0_);
				_tmp44_ = _tmp46_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_regex_unref0 (whitespace);
					info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (_tmp21_);
					b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (_tmp9_);
					_g_object_unref0 (conv_stream);
					_g_object_unref0 (_tmp1_);
					_g_object_unref0 (converter);
					return;
				}
				_tmp47_ = string_strip (_tmp44_);
				line = _tmp47_;
				_tmp48_ = whitespace;
				_tmp49_ = line;
				_tmp51_ = _tmp50_ = g_regex_split (_tmp48_, _tmp49_, 0);
				values = _tmp51_;
				values_length1 = _vala_array_length (_tmp50_);
				_values_size_ = values_length1;
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp52_ = FALSE;
						_tmp52_ = TRUE;
						while (TRUE) {
							gchar** _tmp54_;
							gint _tmp54__length1;
							const gchar* _tmp55_;
							gchar* _tmp56_;
							gchar* _tmp57_;
							gboolean _tmp58_;
							if (!_tmp52_) {
								gint _tmp53_;
								_tmp53_ = j;
								j = _tmp53_ + 1;
							}
							_tmp52_ = FALSE;
							if (!(j < item_count)) {
								break;
							}
							_tmp54_ = values;
							_tmp54__length1 = values_length1;
							_tmp55_ = _tmp54_[j];
							_tmp56_ = g_utf8_strdown (_tmp55_, (gssize) -1);
							_tmp57_ = _tmp56_;
							_tmp58_ = !(g_strcmp0 (_tmp57_, "nan") == 0);
							_g_free0 (_tmp57_);
							if (_tmp58_) {
								gdouble _tmp59_ = 0.0;
								gchar** _tmp60_;
								gint _tmp60__length1;
								const gchar* _tmp61_;
								GraphsXryColumn** _tmp62_;
								gint _tmp62__length1;
								GraphsXryColumn* _tmp63_;
								gdouble* _tmp64_;
								gint _tmp64__length1;
								GraphsXryColumn** _tmp65_;
								gint _tmp65__length1;
								GraphsXryColumn* _tmp66_;
								gint* _tmp67_;
								GraphsXryColumn** _tmp71_;
								gint _tmp71__length1;
								GraphsXryColumn* _tmp72_;
								_tmp60_ = values;
								_tmp60__length1 = values_length1;
								_tmp61_ = _tmp60_[j];
								_tmp59_ = graphs_evaluate_string (_tmp61_, &_inner_error0_);
								if (G_UNLIKELY (_inner_error0_ != NULL)) {
									g_propagate_error (error, _inner_error0_);
									values = (_vala_array_free (values, values_length1, (GDestroyNotify) g_free), NULL);
									_g_free0 (line);
									_g_free0 (_tmp44_);
									_g_regex_unref0 (whitespace);
									info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
									_g_free0 (_tmp21_);
									b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
									_g_free0 (_tmp9_);
									_g_object_unref0 (conv_stream);
									_g_object_unref0 (_tmp1_);
									_g_object_unref0 (converter);
									return;
								}
								_tmp62_ = self->priv->columns;
								_tmp62__length1 = self->priv->columns_length1;
								_tmp63_ = _tmp62_[j];
								_tmp64_ = _tmp63_->data;
								_tmp64__length1 = _tmp63_->data_length1;
								_tmp64_[i] = _tmp59_;
								_tmp65_ = self->priv->columns;
								_tmp65__length1 = self->priv->columns_length1;
								_tmp66_ = _tmp65_[j];
								_tmp67_ = _tmp66_->first_val;
								if (_tmp67_ == NULL) {
									GraphsXryColumn** _tmp68_;
									gint _tmp68__length1;
									GraphsXryColumn* _tmp69_;
									gint* _tmp70_;
									_tmp68_ = self->priv->columns;
									_tmp68__length1 = self->priv->columns_length1;
									_tmp69_ = _tmp68_[j];
									_tmp70_ = __int_dup0 (&i);
									_g_free0 (_tmp69_->first_val);
									_tmp69_->first_val = _tmp70_;
								}
								_tmp71_ = self->priv->columns;
								_tmp71__length1 = self->priv->columns_length1;
								_tmp72_ = _tmp71_[j];
								_tmp72_->last_val = i;
							}
						}
					}
				}
				_tmp73_ = self->priv->xdata;
				_tmp73__length1 = self->priv->xdata_length1;
				_tmp73_[i] = x_value;
				x_value += x_step;
				values = (_vala_array_free (values, values_length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (line);
				_g_free0 (_tmp44_);
			}
		}
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp74_ = FALSE;
			_tmp74_ = TRUE;
			while (TRUE) {
				GraphsXryColumn* column = NULL;
				GraphsXryColumn** _tmp76_;
				gint _tmp76__length1;
				GraphsXryColumn* _tmp77_;
				GraphsXryColumn* _tmp78_;
				gint* _tmp79_;
				gint _tmp80_;
				GraphsXryColumn* _tmp89_;
				GraphsXryColumn* _tmp90_;
				gdouble* _tmp91_;
				gint _tmp91__length1;
				GraphsXryColumn* _tmp92_;
				gint* _tmp93_;
				gchar* name = NULL;
				const gchar* _tmp99_;
				const gchar* _tmp100_;
				gchar* _tmp101_;
				gdouble* xdata = NULL;
				gdouble* _tmp104_;
				gint _tmp104__length1;
				GraphsXryColumn* _tmp105_;
				gint* _tmp106_;
				GraphsXryColumn* _tmp107_;
				gdouble* _tmp108_;
				gint _tmp108__length1;
				gint xdata_length1;
				gint _xdata_size_;
				GraphsDataItem* item = NULL;
				gdouble* _tmp109_;
				gint _tmp109__length1;
				GraphsXryColumn* _tmp110_;
				gdouble* _tmp111_;
				gint _tmp111__length1;
				GraphsDataItem* _tmp112_;
				GraphsDataItem* _tmp113_;
				const gchar* _tmp114_;
				GraphsDataItem* _tmp115_;
				GraphsDataItem* _tmp116_;
				GraphsDataItem* _tmp117_;
				if (!_tmp74_) {
					gint _tmp75_;
					_tmp75_ = i;
					i = _tmp75_ + 1;
				}
				_tmp74_ = FALSE;
				if (!(i < item_count)) {
					break;
				}
				_tmp76_ = self->priv->columns;
				_tmp76__length1 = self->priv->columns_length1;
				_tmp77_ = _tmp76_[i];
				column = _tmp77_;
				_tmp78_ = column;
				_tmp79_ = _tmp78_->first_val;
				_tmp80_ = 0;
				if (_int_equal (_tmp79_, &_tmp80_) != TRUE) {
					GraphsXryColumn* _tmp81_;
					GraphsXryColumn* _tmp82_;
					gdouble* _tmp83_;
					gint _tmp83__length1;
					GraphsXryColumn* _tmp84_;
					gint* _tmp85_;
					GraphsXryColumn* _tmp86_;
					gdouble* _tmp87_;
					gint _tmp87__length1;
					gdouble* _tmp88_;
					gint _tmp88__length1;
					_tmp81_ = column;
					_tmp82_ = column;
					_tmp83_ = _tmp82_->data;
					_tmp83__length1 = _tmp82_->data_length1;
					_tmp84_ = column;
					_tmp85_ = _tmp84_->first_val;
					_tmp86_ = column;
					_tmp87_ = _tmp86_->data;
					_tmp87__length1 = _tmp86_->data_length1;
					_tmp88_ = (_tmp87_ != NULL) ? _vala_array_dup8 (_tmp87_ + (*_tmp85_), _tmp87__length1 - (*_tmp85_)) : _tmp87_;
					_tmp88__length1 = _tmp87__length1 - (*_tmp85_);
					_tmp81_->data = (g_free (_tmp81_->data), NULL);
					_tmp81_->data = _tmp88_;
					_tmp81_->data_length1 = _tmp88__length1;
					_tmp81_->_data_size_ = _tmp81_->data_length1;
				}
				_tmp89_ = column;
				_tmp90_ = column;
				_tmp91_ = _tmp90_->data;
				_tmp91__length1 = _tmp90_->data_length1;
				_tmp92_ = column;
				_tmp93_ = _tmp92_->first_val;
				if (_tmp89_->last_val != ((_tmp91__length1 - 1) + (*_tmp93_))) {
					GraphsXryColumn* _tmp94_;
					GraphsXryColumn* _tmp95_;
					GraphsXryColumn* _tmp96_;
					gint* _tmp97_;
					gint _tmp98_;
					_tmp94_ = column;
					_tmp95_ = column;
					_tmp96_ = column;
					_tmp97_ = _tmp96_->first_val;
					_tmp98_ = (_tmp95_->last_val - (*_tmp97_)) + 1;
					_tmp94_->data = g_renew (gdouble, _tmp94_->data, (_tmp95_->last_val - (*_tmp97_)) + 1);
					(_tmp98_ > _tmp94_->data_length1) ? memset (_tmp94_->data + _tmp94_->data_length1, 0, sizeof (gdouble) * (_tmp98_ - _tmp94_->data_length1)) : NULL;
					_tmp94_->data_length1 = _tmp98_;
					_tmp94_->_data_size_ = _tmp98_;
				}
				_tmp99_ = graphs_import_settings_get_filename (settings);
				_tmp100_ = _tmp99_;
				_tmp101_ = g_strdup (_tmp100_);
				name = _tmp101_;
				if (item_count > 1) {
					const gchar* _tmp102_;
					gchar* _tmp103_;
					_tmp102_ = name;
					_tmp103_ = g_strdup_printf ("%s - %d", _tmp102_, i + 1);
					_g_free0 (name);
					name = _tmp103_;
				}
				_tmp104_ = self->priv->xdata;
				_tmp104__length1 = self->priv->xdata_length1;
				_tmp105_ = column;
				_tmp106_ = _tmp105_->first_val;
				_tmp107_ = column;
				_tmp108_ = (_tmp104_ != NULL) ? _vala_array_dup9 (_tmp104_ + (*_tmp106_), (_tmp107_->last_val + 1) - (*_tmp106_)) : _tmp104_;
				_tmp108__length1 = (_tmp107_->last_val + 1) - (*_tmp106_);
				xdata = _tmp108_;
				xdata_length1 = _tmp108__length1;
				_xdata_size_ = xdata_length1;
				_tmp109_ = xdata;
				_tmp109__length1 = xdata_length1;
				_tmp110_ = column;
				_tmp111_ = _tmp110_->data;
				_tmp111__length1 = _tmp110_->data_length1;
				_tmp112_ = graphs_item_factory_new_data_item (data, _tmp109_, (gint) _tmp109__length1, _tmp111_, (gint) _tmp111__length1, NULL, (gint) 0, NULL, (gint) 0);
				item = _tmp112_;
				_tmp113_ = item;
				_tmp114_ = name;
				graphs_item_set_name ((GraphsItem*) _tmp113_, _tmp114_);
				_tmp115_ = item;
				graphs_item_set_xlabel ((GraphsItem*) _tmp115_, _ ("β (°)"));
				_tmp116_ = item;
				graphs_item_set_ylabel ((GraphsItem*) _tmp116_, _ ("R (1/s)"));
				_tmp117_ = item;
				graphs_item_list_add (items, (GraphsItem*) _tmp117_);
				_g_object_unref0 (item);
				xdata = (g_free (xdata), NULL);
				_g_free0 (name);
			}
		}
	}
	graphs_xry_parser_skip (self, 9 + item_count, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_regex_unref0 (whitespace);
		info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp21_);
		b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp9_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	_tmp119_ = self->priv->input;
	_tmp120_ = g_data_input_stream_read_line (_tmp119_, NULL, NULL, &_inner_error0_);
	_tmp118_ = _tmp120_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_regex_unref0 (whitespace);
		info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp21_);
		b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp9_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	_tmp121_ = graphs_evaluate_string (_tmp118_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_free0 (_tmp118_);
		_g_regex_unref0 (whitespace);
		info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp21_);
		b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp9_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	text_item_count = (gint) _tmp121_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp122_ = FALSE;
			_tmp122_ = TRUE;
			while (TRUE) {
				gchar* _tmp124_ = NULL;
				GDataInputStream* _tmp125_;
				gchar* _tmp126_;
				gchar** values = NULL;
				gchar* _tmp127_;
				gchar* _tmp128_;
				gchar** _tmp129_;
				gchar** _tmp130_;
				gchar** _tmp131_;
				gint _tmp131__length1;
				gint values_length1;
				gint _values_size_;
				gdouble xanchor = 0.0;
				gchar** _tmp132_;
				gint _tmp132__length1;
				const gchar* _tmp133_;
				gdouble yanchor = 0.0;
				gchar** _tmp134_;
				gint _tmp134__length1;
				const gchar* _tmp135_;
				gchar* text = NULL;
				gchar** _tmp136_;
				gint _tmp136__length1;
				gchar** _tmp137_;
				gint _tmp137__length1;
				gchar* _tmp138_;
				GraphsTextItem* item = NULL;
				const gchar* _tmp139_;
				GraphsTextItem* _tmp140_;
				GraphsTextItem* _tmp141_;
				const gchar* _tmp142_;
				GraphsTextItem* _tmp143_;
				if (!_tmp122_) {
					gint _tmp123_;
					_tmp123_ = i;
					i = _tmp123_ + 1;
				}
				_tmp122_ = FALSE;
				if (!(i < text_item_count)) {
					break;
				}
				_tmp125_ = self->priv->input;
				_tmp126_ = g_data_input_stream_read_line (_tmp125_, NULL, NULL, &_inner_error0_);
				_tmp124_ = _tmp126_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_free0 (_tmp118_);
					_g_regex_unref0 (whitespace);
					info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (_tmp21_);
					b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (_tmp9_);
					_g_object_unref0 (conv_stream);
					_g_object_unref0 (_tmp1_);
					_g_object_unref0 (converter);
					return;
				}
				_tmp127_ = string_strip (_tmp124_);
				_tmp128_ = _tmp127_;
				_tmp130_ = _tmp129_ = g_strsplit (_tmp128_, " ", 0);
				_tmp131_ = _tmp130_;
				_tmp131__length1 = _vala_array_length (_tmp129_);
				_g_free0 (_tmp128_);
				values = _tmp131_;
				values_length1 = _tmp131__length1;
				_values_size_ = values_length1;
				_tmp132_ = values;
				_tmp132__length1 = values_length1;
				_tmp133_ = _tmp132_[5];
				xanchor = graphs_evaluate_string (_tmp133_, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					values = (_vala_array_free (values, values_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (_tmp124_);
					_g_free0 (_tmp118_);
					_g_regex_unref0 (whitespace);
					info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (_tmp21_);
					b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (_tmp9_);
					_g_object_unref0 (conv_stream);
					_g_object_unref0 (_tmp1_);
					_g_object_unref0 (converter);
					return;
				}
				_tmp134_ = values;
				_tmp134__length1 = values_length1;
				_tmp135_ = _tmp134_[6];
				yanchor = graphs_evaluate_string (_tmp135_, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					values = (_vala_array_free (values, values_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (_tmp124_);
					_g_free0 (_tmp118_);
					_g_regex_unref0 (whitespace);
					info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (_tmp21_);
					b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (_tmp9_);
					_g_object_unref0 (conv_stream);
					_g_object_unref0 (_tmp1_);
					_g_object_unref0 (converter);
					return;
				}
				_tmp136_ = values;
				_tmp136__length1 = values_length1;
				_tmp137_ = values;
				_tmp137__length1 = values_length1;
				_tmp138_ = _vala_g_strjoinv (" ", _tmp137_ + 7, (gint) (_tmp137__length1 - 7));
				text = _tmp138_;
				_tmp139_ = text;
				_tmp140_ = graphs_item_factory_new_text_item (data, xanchor, yanchor, _tmp139_);
				item = _tmp140_;
				_tmp141_ = item;
				_tmp142_ = text;
				graphs_item_set_name ((GraphsItem*) _tmp141_, _tmp142_);
				_tmp143_ = item;
				graphs_item_list_add (items, (GraphsItem*) _tmp143_);
				_g_object_unref0 (item);
				_g_free0 (text);
				values = (_vala_array_free (values, values_length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (_tmp124_);
			}
		}
	}
	_tmp144_ = self->priv->input;
	g_input_stream_close ((GInputStream*) _tmp144_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_free0 (_tmp118_);
		_g_regex_unref0 (whitespace);
		info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp21_);
		b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp9_);
		_g_object_unref0 (conv_stream);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (converter);
		return;
	}
	_g_free0 (_tmp118_);
	_g_regex_unref0 (whitespace);
	info = (_vala_array_free (info, info_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (_tmp21_);
	b_params = (_vala_array_free (b_params, b_params_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (_tmp9_);
	_g_object_unref0 (conv_stream);
	_g_object_unref0 (_tmp1_);
	_g_object_unref0 (converter);
}

GraphsXryParser*
graphs_xry_parser_construct (GType object_type)
{
	GraphsXryParser * self = NULL;
	self = (GraphsXryParser*) g_object_new (object_type, NULL);
	return self;
}

GraphsXryParser*
graphs_xry_parser_new (void)
{
	return graphs_xry_parser_construct (GRAPHS_TYPE_XRY_PARSER);
}

static void
graphs_xry_parser_class_init (GraphsXryParserClass * klass,
                              gpointer klass_data)
{
	graphs_xry_parser_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsXryParser_private_offset);
	G_OBJECT_CLASS (klass)->finalize = graphs_xry_parser_finalize;
}

static void
graphs_xry_parser_instance_init (GraphsXryParser * self,
                                 gpointer klass)
{
	self->priv = graphs_xry_parser_get_instance_private (self);
}

static void
graphs_xry_parser_finalize (GObject * obj)
{
	GraphsXryParser * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_XRY_PARSER, GraphsXryParser);
	_g_object_unref0 (self->priv->input);
	self->priv->columns = (_vala_array_free (self->priv->columns, self->priv->columns_length1, (GDestroyNotify) graphs_xry_column_free), NULL);
	self->priv->xdata = (g_free (self->priv->xdata), NULL);
	G_OBJECT_CLASS (graphs_xry_parser_parent_class)->finalize (obj);
}

/**
     * Reader class for parsing xry files
     */
static GType
graphs_xry_parser_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsXryParserClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_xry_parser_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsXryParser), 0, (GInstanceInitFunc) graphs_xry_parser_instance_init, NULL };
	GType graphs_xry_parser_type_id;
	graphs_xry_parser_type_id = g_type_register_static (G_TYPE_OBJECT, "GraphsXryParser", &g_define_type_info, 0);
	GraphsXryParser_private_offset = g_type_add_instance_private (graphs_xry_parser_type_id, sizeof (GraphsXryParserPrivate));
	return graphs_xry_parser_type_id;
}

GType
graphs_xry_parser_get_type (void)
{
	static volatile gsize graphs_xry_parser_type_id__once = 0;
	if (g_once_init_enter (&graphs_xry_parser_type_id__once)) {
		GType graphs_xry_parser_type_id;
		graphs_xry_parser_type_id = graphs_xry_parser_get_type_once ();
		g_once_init_leave (&graphs_xry_parser_type_id__once, graphs_xry_parser_type_id);
	}
	return graphs_xry_parser_type_id__once;
}

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;
}

