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


#include <glib.h>
#include <glib-object.h>
#include <gobject/gvaluecollector.h>


#define TYPE_TILE (tile_get_type ())
#define TILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TILE, Tile))
#define TILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TILE, TileClass))
#define IS_TILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TILE))
#define IS_TILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TILE))
#define TILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TILE, TileClass))

typedef struct _Tile Tile;
typedef struct _TileClass TileClass;
typedef struct _TilePrivate TilePrivate;
typedef struct _ParamSpecTile ParamSpecTile;

#define TYPE_PUZZLE (puzzle_get_type ())
#define PUZZLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PUZZLE, Puzzle))
#define PUZZLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PUZZLE, PuzzleClass))
#define IS_PUZZLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PUZZLE))
#define IS_PUZZLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PUZZLE))
#define PUZZLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PUZZLE, PuzzleClass))

typedef struct _Puzzle Puzzle;
typedef struct _PuzzleClass PuzzleClass;
typedef struct _PuzzlePrivate PuzzlePrivate;
#define _tile_unref0(var) ((var == NULL) ? NULL : (var = (tile_unref (var), NULL)))
#define __g_list_free__tile_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__tile_unref0_ (var), NULL)))
typedef struct _ParamSpecPuzzle ParamSpecPuzzle;

struct _Tile {
	GTypeInstance parent_instance;
	volatile int ref_count;
	TilePrivate * priv;
	gint north;
	gint west;
	gint east;
	gint south;
	guint x;
	guint y;
};

struct _TileClass {
	GTypeClass parent_class;
	void (*finalize) (Tile *self);
};

struct _ParamSpecTile {
	GParamSpec parent_instance;
};

struct _Puzzle {
	GTypeInstance parent_instance;
	volatile int ref_count;
	PuzzlePrivate * priv;
};

struct _PuzzleClass {
	GTypeClass parent_class;
	void (*finalize) (Puzzle *self);
};

struct _PuzzlePrivate {
	guint _size;
	Tile** board;
	gint board_length1;
	gint board_length2;
};

struct _ParamSpecPuzzle {
	GParamSpec parent_instance;
};


static gpointer tile_parent_class = NULL;
static gpointer puzzle_parent_class = NULL;

gpointer tile_ref (gpointer instance);
void tile_unref (gpointer instance);
GParamSpec* param_spec_tile (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_tile (GValue* value, gpointer v_object);
void value_take_tile (GValue* value, gpointer v_object);
gpointer value_get_tile (const GValue* value);
GType tile_get_type (void) G_GNUC_CONST;
enum  {
	TILE_DUMMY_PROPERTY
};
Tile* tile_new (guint x, guint y);
Tile* tile_construct (GType object_type, guint x, guint y);
static void tile_finalize (Tile* obj);
gpointer puzzle_ref (gpointer instance);
void puzzle_unref (gpointer instance);
GParamSpec* param_spec_puzzle (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_puzzle (GValue* value, gpointer v_object);
void value_take_puzzle (GValue* value, gpointer v_object);
gpointer value_get_puzzle (const GValue* value);
GType puzzle_get_type (void) G_GNUC_CONST;
#define PUZZLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PUZZLE, PuzzlePrivate))
enum  {
	PUZZLE_DUMMY_PROPERTY
};
Puzzle* puzzle_new (guint size);
Puzzle* puzzle_construct (GType object_type, guint size);
static void _tile_unref0_ (gpointer var);
static void _g_list_free__tile_unref0_ (GList* self);
Tile* puzzle_get_tile (Puzzle* self, guint x, guint y);
void puzzle_get_tile_location (Puzzle* self, Tile* tile, guint* x, guint* y);
guint puzzle_get_size (Puzzle* self);
gboolean puzzle_tile_fits (Puzzle* self, guint x0, guint y0, guint x1, guint y1);
gboolean puzzle_can_switch (Puzzle* self, guint x0, guint y0, guint x1, guint y1);
void puzzle_switch_tiles (Puzzle* self, guint x0, guint y0, guint x1, guint y1);
gboolean puzzle_get_is_solved (Puzzle* self);
void puzzle_move_up (Puzzle* self);
gboolean puzzle_get_can_move_up (Puzzle* self);
void puzzle_move_down (Puzzle* self);
gboolean puzzle_get_can_move_down (Puzzle* self);
void puzzle_move_left (Puzzle* self);
gboolean puzzle_get_can_move_left (Puzzle* self);
void puzzle_move_right (Puzzle* self);
gboolean puzzle_get_can_move_right (Puzzle* self);
void puzzle_solve (Puzzle* self);
static void g_cclosure_user_marshal_VOID__TILE_UINT_UINT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static void puzzle_finalize (Puzzle* obj);
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);


Tile* tile_construct (GType object_type, guint x, guint y) {
	Tile* self = NULL;
	guint _tmp0_;
	guint _tmp1_;
	self = (Tile*) g_type_create_instance (object_type);
	_tmp0_ = x;
	self->x = _tmp0_;
	_tmp1_ = y;
	self->y = _tmp1_;
	return self;
}


Tile* tile_new (guint x, guint y) {
	return tile_construct (TYPE_TILE, x, y);
}


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


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


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


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


static gchar* value_tile_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		Tile* 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 = tile_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* value_tile_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	Tile** 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 = tile_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* param_spec_tile (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	ParamSpecTile* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_TILE), 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 value_get_tile (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_TILE), NULL);
	return value->data[0].v_pointer;
}


void value_set_tile (GValue* value, gpointer v_object) {
	Tile* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_TILE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_TILE));
		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;
		tile_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		tile_unref (old);
	}
}


void value_take_tile (GValue* value, gpointer v_object) {
	Tile* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_TILE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_TILE));
		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) {
		tile_unref (old);
	}
}


static void tile_class_init (TileClass * klass) {
	tile_parent_class = g_type_class_peek_parent (klass);
	TILE_CLASS (klass)->finalize = tile_finalize;
}


static void tile_instance_init (Tile * self) {
	self->ref_count = 1;
}


static void tile_finalize (Tile* obj) {
	Tile * self;
	self = TILE (obj);
}


GType tile_get_type (void) {
	static volatile gsize tile_type_id__volatile = 0;
	if (g_once_init_enter (&tile_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { value_tile_init, value_tile_free_value, value_tile_copy_value, value_tile_peek_pointer, "p", value_tile_collect_value, "p", value_tile_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (TileClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tile_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Tile), 0, (GInstanceInitFunc) tile_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 tile_type_id;
		tile_type_id = g_type_register_fundamental (g_type_fundamental_next (), "Tile", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&tile_type_id__volatile, tile_type_id);
	}
	return tile_type_id__volatile;
}


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


void tile_unref (gpointer instance) {
	Tile* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		TILE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}


static gpointer _tile_ref0 (gpointer self) {
	return self ? tile_ref (self) : NULL;
}


static void _tile_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (tile_unref (var), NULL));
}


static void _g_list_free__tile_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _tile_unref0_, NULL);
	g_list_free (self);
}


Puzzle* puzzle_construct (GType object_type, guint size) {
	Puzzle* self = NULL;
	guint _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	Tile** _tmp3_ = NULL;
	GList* tiles;
	self = (Puzzle*) g_type_create_instance (object_type);
	_tmp0_ = size;
	self->priv->_size = _tmp0_;
	_tmp1_ = size;
	_tmp2_ = size;
	_tmp3_ = g_new0 (Tile*, ((_tmp1_ * 2) * _tmp2_) + 1);
	self->priv->board = (_vala_array_free (self->priv->board, self->priv->board_length1 * self->priv->board_length2, (GDestroyNotify) tile_unref), NULL);
	self->priv->board = _tmp3_;
	self->priv->board_length1 = _tmp1_ * 2;
	self->priv->board_length2 = _tmp2_;
	{
		gint x;
		x = 0;
		{
			gboolean _tmp4_;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp5_;
				gint _tmp7_;
				guint _tmp8_;
				_tmp5_ = _tmp4_;
				if (!_tmp5_) {
					gint _tmp6_;
					_tmp6_ = x;
					x = _tmp6_ + 1;
				}
				_tmp4_ = FALSE;
				_tmp7_ = x;
				_tmp8_ = size;
				if (!(((guint) _tmp7_) < _tmp8_)) {
					break;
				}
				{
					gint y;
					y = 0;
					{
						gboolean _tmp9_;
						_tmp9_ = TRUE;
						while (TRUE) {
							gboolean _tmp10_;
							gint _tmp12_;
							guint _tmp13_;
							Tile** _tmp14_;
							gint _tmp14__length1;
							gint _tmp14__length2;
							gint _tmp15_;
							gint _tmp16_;
							gint _tmp17_;
							gint _tmp18_;
							Tile* _tmp19_;
							Tile* _tmp20_;
							_tmp10_ = _tmp9_;
							if (!_tmp10_) {
								gint _tmp11_;
								_tmp11_ = y;
								y = _tmp11_ + 1;
							}
							_tmp9_ = FALSE;
							_tmp12_ = y;
							_tmp13_ = size;
							if (!(((guint) _tmp12_) < _tmp13_)) {
								break;
							}
							_tmp14_ = self->priv->board;
							_tmp14__length1 = self->priv->board_length1;
							_tmp14__length2 = self->priv->board_length2;
							_tmp15_ = x;
							_tmp16_ = y;
							_tmp17_ = x;
							_tmp18_ = y;
							_tmp19_ = tile_new ((guint) _tmp17_, (guint) _tmp18_);
							_tile_unref0 (_tmp14_[(_tmp15_ * _tmp14__length2) + _tmp16_]);
							_tmp14_[(_tmp15_ * _tmp14__length2) + _tmp16_] = _tmp19_;
							_tmp20_ = _tmp14_[(_tmp15_ * _tmp14__length2) + _tmp16_];
						}
					}
				}
			}
		}
	}
	{
		gint x;
		x = 0;
		{
			gboolean _tmp21_;
			_tmp21_ = TRUE;
			while (TRUE) {
				gboolean _tmp22_;
				gint _tmp24_;
				guint _tmp25_;
				_tmp22_ = _tmp21_;
				if (!_tmp22_) {
					gint _tmp23_;
					_tmp23_ = x;
					x = _tmp23_ + 1;
				}
				_tmp21_ = FALSE;
				_tmp24_ = x;
				_tmp25_ = size;
				if (!(((guint) _tmp24_) < _tmp25_)) {
					break;
				}
				{
					gint y;
					y = 0;
					{
						gboolean _tmp26_;
						_tmp26_ = TRUE;
						while (TRUE) {
							gboolean _tmp27_;
							gint _tmp29_;
							guint _tmp30_;
							gint32 _tmp31_ = 0;
							gint32 n;
							gint _tmp32_;
							gint _tmp38_;
							guint _tmp39_;
							_tmp27_ = _tmp26_;
							if (!_tmp27_) {
								gint _tmp28_;
								_tmp28_ = y;
								y = _tmp28_ + 1;
							}
							_tmp26_ = FALSE;
							_tmp29_ = y;
							_tmp30_ = size;
							if (!(((guint) _tmp29_) <= _tmp30_)) {
								break;
							}
							_tmp31_ = g_random_int_range ((gint32) 0, (gint32) 10);
							n = _tmp31_;
							_tmp32_ = y;
							if ((_tmp32_ - 1) >= 0) {
								Tile** _tmp33_;
								gint _tmp33__length1;
								gint _tmp33__length2;
								gint _tmp34_;
								gint _tmp35_;
								Tile* _tmp36_;
								gint32 _tmp37_;
								_tmp33_ = self->priv->board;
								_tmp33__length1 = self->priv->board_length1;
								_tmp33__length2 = self->priv->board_length2;
								_tmp34_ = x;
								_tmp35_ = y;
								_tmp36_ = _tmp33_[(_tmp34_ * _tmp33__length2) + (_tmp35_ - 1)];
								_tmp37_ = n;
								_tmp36_->south = (gint) _tmp37_;
							}
							_tmp38_ = y;
							_tmp39_ = size;
							if (((guint) _tmp38_) < _tmp39_) {
								Tile** _tmp40_;
								gint _tmp40__length1;
								gint _tmp40__length2;
								gint _tmp41_;
								gint _tmp42_;
								Tile* _tmp43_;
								gint32 _tmp44_;
								_tmp40_ = self->priv->board;
								_tmp40__length1 = self->priv->board_length1;
								_tmp40__length2 = self->priv->board_length2;
								_tmp41_ = x;
								_tmp42_ = y;
								_tmp43_ = _tmp40_[(_tmp41_ * _tmp40__length2) + _tmp42_];
								_tmp44_ = n;
								_tmp43_->north = (gint) _tmp44_;
							}
						}
					}
				}
			}
		}
	}
	{
		gint x;
		x = 0;
		{
			gboolean _tmp45_;
			_tmp45_ = TRUE;
			while (TRUE) {
				gboolean _tmp46_;
				gint _tmp48_;
				guint _tmp49_;
				_tmp46_ = _tmp45_;
				if (!_tmp46_) {
					gint _tmp47_;
					_tmp47_ = x;
					x = _tmp47_ + 1;
				}
				_tmp45_ = FALSE;
				_tmp48_ = x;
				_tmp49_ = size;
				if (!(((guint) _tmp48_) <= _tmp49_)) {
					break;
				}
				{
					gint y;
					y = 0;
					{
						gboolean _tmp50_;
						_tmp50_ = TRUE;
						while (TRUE) {
							gboolean _tmp51_;
							gint _tmp53_;
							guint _tmp54_;
							gint32 _tmp55_ = 0;
							gint32 n;
							gint _tmp56_;
							gint _tmp62_;
							guint _tmp63_;
							_tmp51_ = _tmp50_;
							if (!_tmp51_) {
								gint _tmp52_;
								_tmp52_ = y;
								y = _tmp52_ + 1;
							}
							_tmp50_ = FALSE;
							_tmp53_ = y;
							_tmp54_ = size;
							if (!(((guint) _tmp53_) < _tmp54_)) {
								break;
							}
							_tmp55_ = g_random_int_range ((gint32) 0, (gint32) 10);
							n = _tmp55_;
							_tmp56_ = x;
							if ((_tmp56_ - 1) >= 0) {
								Tile** _tmp57_;
								gint _tmp57__length1;
								gint _tmp57__length2;
								gint _tmp58_;
								gint _tmp59_;
								Tile* _tmp60_;
								gint32 _tmp61_;
								_tmp57_ = self->priv->board;
								_tmp57__length1 = self->priv->board_length1;
								_tmp57__length2 = self->priv->board_length2;
								_tmp58_ = x;
								_tmp59_ = y;
								_tmp60_ = _tmp57_[((_tmp58_ - 1) * _tmp57__length2) + _tmp59_];
								_tmp61_ = n;
								_tmp60_->east = (gint) _tmp61_;
							}
							_tmp62_ = x;
							_tmp63_ = size;
							if (((guint) _tmp62_) < _tmp63_) {
								Tile** _tmp64_;
								gint _tmp64__length1;
								gint _tmp64__length2;
								gint _tmp65_;
								gint _tmp66_;
								Tile* _tmp67_;
								gint32 _tmp68_;
								_tmp64_ = self->priv->board;
								_tmp64__length1 = self->priv->board_length1;
								_tmp64__length2 = self->priv->board_length2;
								_tmp65_ = x;
								_tmp66_ = y;
								_tmp67_ = _tmp64_[(_tmp65_ * _tmp64__length2) + _tmp66_];
								_tmp68_ = n;
								_tmp67_->west = (gint) _tmp68_;
							}
						}
					}
				}
			}
		}
	}
	tiles = NULL;
	{
		gint x;
		x = 0;
		{
			gboolean _tmp69_;
			_tmp69_ = TRUE;
			while (TRUE) {
				gboolean _tmp70_;
				gint _tmp72_;
				guint _tmp73_;
				_tmp70_ = _tmp69_;
				if (!_tmp70_) {
					gint _tmp71_;
					_tmp71_ = x;
					x = _tmp71_ + 1;
				}
				_tmp69_ = FALSE;
				_tmp72_ = x;
				_tmp73_ = size;
				if (!(((guint) _tmp72_) < _tmp73_)) {
					break;
				}
				{
					gint y;
					y = 0;
					{
						gboolean _tmp74_;
						_tmp74_ = TRUE;
						while (TRUE) {
							gboolean _tmp75_;
							gint _tmp77_;
							guint _tmp78_;
							Tile** _tmp79_;
							gint _tmp79__length1;
							gint _tmp79__length2;
							gint _tmp80_;
							gint _tmp81_;
							Tile* _tmp82_;
							Tile* _tmp83_;
							Tile** _tmp84_;
							gint _tmp84__length1;
							gint _tmp84__length2;
							gint _tmp85_;
							gint _tmp86_;
							Tile* _tmp87_;
							_tmp75_ = _tmp74_;
							if (!_tmp75_) {
								gint _tmp76_;
								_tmp76_ = y;
								y = _tmp76_ + 1;
							}
							_tmp74_ = FALSE;
							_tmp77_ = y;
							_tmp78_ = size;
							if (!(((guint) _tmp77_) < _tmp78_)) {
								break;
							}
							_tmp79_ = self->priv->board;
							_tmp79__length1 = self->priv->board_length1;
							_tmp79__length2 = self->priv->board_length2;
							_tmp80_ = x;
							_tmp81_ = y;
							_tmp82_ = _tmp79_[(_tmp80_ * _tmp79__length2) + _tmp81_];
							_tmp83_ = _tile_ref0 (_tmp82_);
							tiles = g_list_append (tiles, _tmp83_);
							_tmp84_ = self->priv->board;
							_tmp84__length1 = self->priv->board_length1;
							_tmp84__length2 = self->priv->board_length2;
							_tmp85_ = x;
							_tmp86_ = y;
							_tile_unref0 (_tmp84_[(_tmp85_ * _tmp84__length2) + _tmp86_]);
							_tmp84_[(_tmp85_ * _tmp84__length2) + _tmp86_] = NULL;
							_tmp87_ = _tmp84_[(_tmp85_ * _tmp84__length2) + _tmp86_];
						}
					}
				}
			}
		}
	}
	{
		gint x;
		x = 0;
		{
			gboolean _tmp88_;
			_tmp88_ = TRUE;
			while (TRUE) {
				gboolean _tmp89_;
				gint _tmp91_;
				guint _tmp92_;
				_tmp89_ = _tmp88_;
				if (!_tmp89_) {
					gint _tmp90_;
					_tmp90_ = x;
					x = _tmp90_ + 1;
				}
				_tmp88_ = FALSE;
				_tmp91_ = x;
				_tmp92_ = size;
				if (!(((guint) _tmp91_) < _tmp92_)) {
					break;
				}
				{
					gint y;
					y = 0;
					{
						gboolean _tmp93_;
						_tmp93_ = TRUE;
						while (TRUE) {
							gboolean _tmp94_;
							gint _tmp96_;
							guint _tmp97_;
							GList* _tmp98_;
							guint _tmp99_ = 0U;
							gint32 _tmp100_ = 0;
							gint32 n;
							GList* _tmp101_;
							gint32 _tmp102_;
							gconstpointer _tmp103_ = NULL;
							Tile* _tmp104_;
							Tile* tile;
							Tile** _tmp105_;
							gint _tmp105__length1;
							gint _tmp105__length2;
							gint _tmp106_;
							guint _tmp107_;
							gint _tmp108_;
							Tile* _tmp109_;
							Tile* _tmp110_;
							Tile* _tmp111_;
							Tile* _tmp112_;
							_tmp94_ = _tmp93_;
							if (!_tmp94_) {
								gint _tmp95_;
								_tmp95_ = y;
								y = _tmp95_ + 1;
							}
							_tmp93_ = FALSE;
							_tmp96_ = y;
							_tmp97_ = size;
							if (!(((guint) _tmp96_) < _tmp97_)) {
								break;
							}
							_tmp98_ = tiles;
							_tmp99_ = g_list_length (_tmp98_);
							_tmp100_ = g_random_int_range ((gint32) 0, (gint32) _tmp99_);
							n = _tmp100_;
							_tmp101_ = tiles;
							_tmp102_ = n;
							_tmp103_ = g_list_nth_data (_tmp101_, (guint) _tmp102_);
							_tmp104_ = _tile_ref0 ((Tile*) _tmp103_);
							tile = _tmp104_;
							_tmp105_ = self->priv->board;
							_tmp105__length1 = self->priv->board_length1;
							_tmp105__length2 = self->priv->board_length2;
							_tmp106_ = x;
							_tmp107_ = size;
							_tmp108_ = y;
							_tmp109_ = tile;
							_tmp110_ = _tile_ref0 (_tmp109_);
							_tile_unref0 (_tmp105_[((_tmp106_ + _tmp107_) * _tmp105__length2) + _tmp108_]);
							_tmp105_[((_tmp106_ + _tmp107_) * _tmp105__length2) + _tmp108_] = _tmp110_;
							_tmp111_ = _tmp105_[((_tmp106_ + _tmp107_) * _tmp105__length2) + _tmp108_];
							_tmp112_ = tile;
							tiles = g_list_remove (tiles, _tmp112_);
							_tile_unref0 (tile);
						}
					}
				}
			}
		}
	}
	__g_list_free__tile_unref0_0 (tiles);
	return self;
}


Puzzle* puzzle_new (guint size) {
	return puzzle_construct (TYPE_PUZZLE, size);
}


Tile* puzzle_get_tile (Puzzle* self, guint x, guint y) {
	Tile* result = NULL;
	Tile** _tmp0_;
	gint _tmp0__length1;
	gint _tmp0__length2;
	guint _tmp1_;
	guint _tmp2_;
	Tile* _tmp3_;
	Tile* _tmp4_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->board;
	_tmp0__length1 = self->priv->board_length1;
	_tmp0__length2 = self->priv->board_length2;
	_tmp1_ = x;
	_tmp2_ = y;
	_tmp3_ = _tmp0_[(_tmp1_ * _tmp0__length2) + _tmp2_];
	_tmp4_ = _tile_ref0 (_tmp3_);
	result = _tmp4_;
	return result;
}


void puzzle_get_tile_location (Puzzle* self, Tile* tile, guint* x, guint* y) {
	guint _vala_x = 0U;
	guint _vala_y = 0U;
	guint _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tile != NULL);
	_vala_y = (guint) 0;
	_tmp0_ = _vala_y;
	_vala_x = _tmp0_;
	{
		gboolean _tmp1_;
		_vala_x = (guint) 0;
		_tmp1_ = TRUE;
		while (TRUE) {
			gboolean _tmp2_;
			guint _tmp4_;
			guint _tmp5_;
			guint _tmp6_;
			_tmp2_ = _tmp1_;
			if (!_tmp2_) {
				guint _tmp3_;
				_tmp3_ = _vala_x;
				_vala_x = _tmp3_ + 1;
			}
			_tmp1_ = FALSE;
			_tmp4_ = _vala_x;
			_tmp5_ = puzzle_get_size (self);
			_tmp6_ = _tmp5_;
			if (!(_tmp4_ < (_tmp6_ * 2))) {
				break;
			}
			{
				gboolean _tmp7_;
				_vala_y = (guint) 0;
				_tmp7_ = TRUE;
				while (TRUE) {
					gboolean _tmp8_;
					guint _tmp10_;
					guint _tmp11_;
					guint _tmp12_;
					Tile** _tmp13_;
					gint _tmp13__length1;
					gint _tmp13__length2;
					guint _tmp14_;
					guint _tmp15_;
					Tile* _tmp16_;
					Tile* _tmp17_;
					_tmp8_ = _tmp7_;
					if (!_tmp8_) {
						guint _tmp9_;
						_tmp9_ = _vala_y;
						_vala_y = _tmp9_ + 1;
					}
					_tmp7_ = FALSE;
					_tmp10_ = _vala_y;
					_tmp11_ = puzzle_get_size (self);
					_tmp12_ = _tmp11_;
					if (!(_tmp10_ < _tmp12_)) {
						break;
					}
					_tmp13_ = self->priv->board;
					_tmp13__length1 = self->priv->board_length1;
					_tmp13__length2 = self->priv->board_length2;
					_tmp14_ = _vala_x;
					_tmp15_ = _vala_y;
					_tmp16_ = _tmp13_[(_tmp14_ * _tmp13__length2) + _tmp15_];
					_tmp17_ = tile;
					if (_tmp16_ == _tmp17_) {
						if (x) {
							*x = _vala_x;
						}
						if (y) {
							*y = _vala_y;
						}
						return;
					}
				}
			}
		}
	}
	if (x) {
		*x = _vala_x;
	}
	if (y) {
		*y = _vala_y;
	}
}


gboolean puzzle_tile_fits (Puzzle* self, guint x0, guint y0, guint x1, guint y1) {
	gboolean result = FALSE;
	Tile** _tmp0_;
	gint _tmp0__length1;
	gint _tmp0__length2;
	guint _tmp1_;
	guint _tmp2_;
	Tile* _tmp3_;
	Tile* _tmp4_;
	Tile* tile;
	Tile* _tmp5_;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	guint _tmp9_;
	gboolean _tmp16_;
	gboolean _tmp21_;
	gboolean _tmp29_;
	gboolean _tmp30_ = FALSE;
	gboolean _tmp31_ = FALSE;
	gboolean _tmp32_ = FALSE;
	guint _tmp33_;
	guint _tmp34_;
	guint _tmp35_;
	gboolean _tmp42_;
	gboolean _tmp47_;
	gboolean _tmp55_;
	gboolean _tmp56_ = FALSE;
	gboolean _tmp57_ = FALSE;
	gboolean _tmp58_ = FALSE;
	guint _tmp59_;
	gboolean _tmp66_;
	gboolean _tmp71_;
	gboolean _tmp79_;
	gboolean _tmp80_ = FALSE;
	gboolean _tmp81_ = FALSE;
	gboolean _tmp82_ = FALSE;
	guint _tmp83_;
	guint _tmp84_;
	guint _tmp85_;
	gboolean _tmp92_;
	gboolean _tmp97_;
	gboolean _tmp105_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->board;
	_tmp0__length1 = self->priv->board_length1;
	_tmp0__length2 = self->priv->board_length2;
	_tmp1_ = x0;
	_tmp2_ = y0;
	_tmp3_ = _tmp0_[(_tmp1_ * _tmp0__length2) + _tmp2_];
	_tmp4_ = _tile_ref0 (_tmp3_);
	tile = _tmp4_;
	_tmp5_ = tile;
	if (_tmp5_ == NULL) {
		result = FALSE;
		_tile_unref0 (tile);
		return result;
	}
	_tmp9_ = x1;
	if (_tmp9_ > ((guint) 0)) {
		gboolean _tmp10_ = FALSE;
		guint _tmp11_;
		guint _tmp12_;
		gboolean _tmp15_;
		_tmp11_ = x1;
		_tmp12_ = x0;
		if ((_tmp11_ - 1) == _tmp12_) {
			guint _tmp13_;
			guint _tmp14_;
			_tmp13_ = y1;
			_tmp14_ = y0;
			_tmp10_ = _tmp13_ == _tmp14_;
		} else {
			_tmp10_ = FALSE;
		}
		_tmp15_ = _tmp10_;
		_tmp8_ = !_tmp15_;
	} else {
		_tmp8_ = FALSE;
	}
	_tmp16_ = _tmp8_;
	if (_tmp16_) {
		Tile** _tmp17_;
		gint _tmp17__length1;
		gint _tmp17__length2;
		guint _tmp18_;
		guint _tmp19_;
		Tile* _tmp20_;
		_tmp17_ = self->priv->board;
		_tmp17__length1 = self->priv->board_length1;
		_tmp17__length2 = self->priv->board_length2;
		_tmp18_ = x1;
		_tmp19_ = y1;
		_tmp20_ = _tmp17_[((_tmp18_ - 1) * _tmp17__length2) + _tmp19_];
		_tmp7_ = _tmp20_ != NULL;
	} else {
		_tmp7_ = FALSE;
	}
	_tmp21_ = _tmp7_;
	if (_tmp21_) {
		Tile** _tmp22_;
		gint _tmp22__length1;
		gint _tmp22__length2;
		guint _tmp23_;
		guint _tmp24_;
		Tile* _tmp25_;
		gint _tmp26_;
		Tile* _tmp27_;
		gint _tmp28_;
		_tmp22_ = self->priv->board;
		_tmp22__length1 = self->priv->board_length1;
		_tmp22__length2 = self->priv->board_length2;
		_tmp23_ = x1;
		_tmp24_ = y1;
		_tmp25_ = _tmp22_[((_tmp23_ - 1) * _tmp22__length2) + _tmp24_];
		_tmp26_ = _tmp25_->east;
		_tmp27_ = tile;
		_tmp28_ = _tmp27_->west;
		_tmp6_ = _tmp26_ != _tmp28_;
	} else {
		_tmp6_ = FALSE;
	}
	_tmp29_ = _tmp6_;
	if (_tmp29_) {
		result = FALSE;
		_tile_unref0 (tile);
		return result;
	}
	_tmp33_ = x1;
	_tmp34_ = puzzle_get_size (self);
	_tmp35_ = _tmp34_;
	if (_tmp33_ < (_tmp35_ - 1)) {
		gboolean _tmp36_ = FALSE;
		guint _tmp37_;
		guint _tmp38_;
		gboolean _tmp41_;
		_tmp37_ = x1;
		_tmp38_ = x0;
		if ((_tmp37_ + 1) == _tmp38_) {
			guint _tmp39_;
			guint _tmp40_;
			_tmp39_ = y1;
			_tmp40_ = y0;
			_tmp36_ = _tmp39_ == _tmp40_;
		} else {
			_tmp36_ = FALSE;
		}
		_tmp41_ = _tmp36_;
		_tmp32_ = !_tmp41_;
	} else {
		_tmp32_ = FALSE;
	}
	_tmp42_ = _tmp32_;
	if (_tmp42_) {
		Tile** _tmp43_;
		gint _tmp43__length1;
		gint _tmp43__length2;
		guint _tmp44_;
		guint _tmp45_;
		Tile* _tmp46_;
		_tmp43_ = self->priv->board;
		_tmp43__length1 = self->priv->board_length1;
		_tmp43__length2 = self->priv->board_length2;
		_tmp44_ = x1;
		_tmp45_ = y1;
		_tmp46_ = _tmp43_[((_tmp44_ + 1) * _tmp43__length2) + _tmp45_];
		_tmp31_ = _tmp46_ != NULL;
	} else {
		_tmp31_ = FALSE;
	}
	_tmp47_ = _tmp31_;
	if (_tmp47_) {
		Tile** _tmp48_;
		gint _tmp48__length1;
		gint _tmp48__length2;
		guint _tmp49_;
		guint _tmp50_;
		Tile* _tmp51_;
		gint _tmp52_;
		Tile* _tmp53_;
		gint _tmp54_;
		_tmp48_ = self->priv->board;
		_tmp48__length1 = self->priv->board_length1;
		_tmp48__length2 = self->priv->board_length2;
		_tmp49_ = x1;
		_tmp50_ = y1;
		_tmp51_ = _tmp48_[((_tmp49_ + 1) * _tmp48__length2) + _tmp50_];
		_tmp52_ = _tmp51_->west;
		_tmp53_ = tile;
		_tmp54_ = _tmp53_->east;
		_tmp30_ = _tmp52_ != _tmp54_;
	} else {
		_tmp30_ = FALSE;
	}
	_tmp55_ = _tmp30_;
	if (_tmp55_) {
		result = FALSE;
		_tile_unref0 (tile);
		return result;
	}
	_tmp59_ = y1;
	if (_tmp59_ > ((guint) 0)) {
		gboolean _tmp60_ = FALSE;
		guint _tmp61_;
		guint _tmp62_;
		gboolean _tmp65_;
		_tmp61_ = x1;
		_tmp62_ = x0;
		if (_tmp61_ == _tmp62_) {
			guint _tmp63_;
			guint _tmp64_;
			_tmp63_ = y1;
			_tmp64_ = y0;
			_tmp60_ = (_tmp63_ - 1) == _tmp64_;
		} else {
			_tmp60_ = FALSE;
		}
		_tmp65_ = _tmp60_;
		_tmp58_ = !_tmp65_;
	} else {
		_tmp58_ = FALSE;
	}
	_tmp66_ = _tmp58_;
	if (_tmp66_) {
		Tile** _tmp67_;
		gint _tmp67__length1;
		gint _tmp67__length2;
		guint _tmp68_;
		guint _tmp69_;
		Tile* _tmp70_;
		_tmp67_ = self->priv->board;
		_tmp67__length1 = self->priv->board_length1;
		_tmp67__length2 = self->priv->board_length2;
		_tmp68_ = x1;
		_tmp69_ = y1;
		_tmp70_ = _tmp67_[(_tmp68_ * _tmp67__length2) + (_tmp69_ - 1)];
		_tmp57_ = _tmp70_ != NULL;
	} else {
		_tmp57_ = FALSE;
	}
	_tmp71_ = _tmp57_;
	if (_tmp71_) {
		Tile** _tmp72_;
		gint _tmp72__length1;
		gint _tmp72__length2;
		guint _tmp73_;
		guint _tmp74_;
		Tile* _tmp75_;
		gint _tmp76_;
		Tile* _tmp77_;
		gint _tmp78_;
		_tmp72_ = self->priv->board;
		_tmp72__length1 = self->priv->board_length1;
		_tmp72__length2 = self->priv->board_length2;
		_tmp73_ = x1;
		_tmp74_ = y1;
		_tmp75_ = _tmp72_[(_tmp73_ * _tmp72__length2) + (_tmp74_ - 1)];
		_tmp76_ = _tmp75_->south;
		_tmp77_ = tile;
		_tmp78_ = _tmp77_->north;
		_tmp56_ = _tmp76_ != _tmp78_;
	} else {
		_tmp56_ = FALSE;
	}
	_tmp79_ = _tmp56_;
	if (_tmp79_) {
		result = FALSE;
		_tile_unref0 (tile);
		return result;
	}
	_tmp83_ = y1;
	_tmp84_ = puzzle_get_size (self);
	_tmp85_ = _tmp84_;
	if (_tmp83_ < (_tmp85_ - 1)) {
		gboolean _tmp86_ = FALSE;
		guint _tmp87_;
		guint _tmp88_;
		gboolean _tmp91_;
		_tmp87_ = x1;
		_tmp88_ = x0;
		if (_tmp87_ == _tmp88_) {
			guint _tmp89_;
			guint _tmp90_;
			_tmp89_ = y1;
			_tmp90_ = y0;
			_tmp86_ = (_tmp89_ + 1) == _tmp90_;
		} else {
			_tmp86_ = FALSE;
		}
		_tmp91_ = _tmp86_;
		_tmp82_ = !_tmp91_;
	} else {
		_tmp82_ = FALSE;
	}
	_tmp92_ = _tmp82_;
	if (_tmp92_) {
		Tile** _tmp93_;
		gint _tmp93__length1;
		gint _tmp93__length2;
		guint _tmp94_;
		guint _tmp95_;
		Tile* _tmp96_;
		_tmp93_ = self->priv->board;
		_tmp93__length1 = self->priv->board_length1;
		_tmp93__length2 = self->priv->board_length2;
		_tmp94_ = x1;
		_tmp95_ = y1;
		_tmp96_ = _tmp93_[(_tmp94_ * _tmp93__length2) + (_tmp95_ + 1)];
		_tmp81_ = _tmp96_ != NULL;
	} else {
		_tmp81_ = FALSE;
	}
	_tmp97_ = _tmp81_;
	if (_tmp97_) {
		Tile** _tmp98_;
		gint _tmp98__length1;
		gint _tmp98__length2;
		guint _tmp99_;
		guint _tmp100_;
		Tile* _tmp101_;
		gint _tmp102_;
		Tile* _tmp103_;
		gint _tmp104_;
		_tmp98_ = self->priv->board;
		_tmp98__length1 = self->priv->board_length1;
		_tmp98__length2 = self->priv->board_length2;
		_tmp99_ = x1;
		_tmp100_ = y1;
		_tmp101_ = _tmp98_[(_tmp99_ * _tmp98__length2) + (_tmp100_ + 1)];
		_tmp102_ = _tmp101_->north;
		_tmp103_ = tile;
		_tmp104_ = _tmp103_->south;
		_tmp80_ = _tmp102_ != _tmp104_;
	} else {
		_tmp80_ = FALSE;
	}
	_tmp105_ = _tmp80_;
	if (_tmp105_) {
		result = FALSE;
		_tile_unref0 (tile);
		return result;
	}
	result = TRUE;
	_tile_unref0 (tile);
	return result;
}


gboolean puzzle_can_switch (Puzzle* self, guint x0, guint y0, guint x1, guint y1) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	guint _tmp1_;
	guint _tmp2_;
	gboolean _tmp5_;
	Tile** _tmp6_;
	gint _tmp6__length1;
	gint _tmp6__length2;
	guint _tmp7_;
	guint _tmp8_;
	Tile* _tmp9_;
	Tile* _tmp10_;
	Tile* t0;
	Tile** _tmp11_;
	gint _tmp11__length1;
	gint _tmp11__length2;
	guint _tmp12_;
	guint _tmp13_;
	Tile* _tmp14_;
	Tile* _tmp15_;
	Tile* t1;
	gboolean _tmp16_ = FALSE;
	Tile* _tmp17_;
	gboolean _tmp19_;
	gboolean _tmp20_ = FALSE;
	gboolean _tmp21_ = FALSE;
	Tile* _tmp22_;
	gboolean _tmp26_;
	gboolean _tmp32_;
	gboolean _tmp33_ = FALSE;
	gboolean _tmp34_ = FALSE;
	Tile* _tmp35_;
	gboolean _tmp39_;
	gboolean _tmp45_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = x0;
	_tmp2_ = x1;
	if (_tmp1_ == _tmp2_) {
		guint _tmp3_;
		guint _tmp4_;
		_tmp3_ = y0;
		_tmp4_ = y1;
		_tmp0_ = _tmp3_ == _tmp4_;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp5_ = _tmp0_;
	if (_tmp5_) {
		result = FALSE;
		return result;
	}
	_tmp6_ = self->priv->board;
	_tmp6__length1 = self->priv->board_length1;
	_tmp6__length2 = self->priv->board_length2;
	_tmp7_ = x0;
	_tmp8_ = y0;
	_tmp9_ = _tmp6_[(_tmp7_ * _tmp6__length2) + _tmp8_];
	_tmp10_ = _tile_ref0 (_tmp9_);
	t0 = _tmp10_;
	_tmp11_ = self->priv->board;
	_tmp11__length1 = self->priv->board_length1;
	_tmp11__length2 = self->priv->board_length2;
	_tmp12_ = x1;
	_tmp13_ = y1;
	_tmp14_ = _tmp11_[(_tmp12_ * _tmp11__length2) + _tmp13_];
	_tmp15_ = _tile_ref0 (_tmp14_);
	t1 = _tmp15_;
	_tmp17_ = t0;
	if (_tmp17_ == NULL) {
		Tile* _tmp18_;
		_tmp18_ = t1;
		_tmp16_ = _tmp18_ == NULL;
	} else {
		_tmp16_ = FALSE;
	}
	_tmp19_ = _tmp16_;
	if (_tmp19_) {
		result = FALSE;
		_tile_unref0 (t1);
		_tile_unref0 (t0);
		return result;
	}
	_tmp22_ = t0;
	if (_tmp22_ != NULL) {
		guint _tmp23_;
		guint _tmp24_;
		guint _tmp25_;
		_tmp23_ = x1;
		_tmp24_ = puzzle_get_size (self);
		_tmp25_ = _tmp24_;
		_tmp21_ = _tmp23_ < _tmp25_;
	} else {
		_tmp21_ = FALSE;
	}
	_tmp26_ = _tmp21_;
	if (_tmp26_) {
		guint _tmp27_;
		guint _tmp28_;
		guint _tmp29_;
		guint _tmp30_;
		gboolean _tmp31_ = FALSE;
		_tmp27_ = x0;
		_tmp28_ = y0;
		_tmp29_ = x1;
		_tmp30_ = y1;
		_tmp31_ = puzzle_tile_fits (self, _tmp27_, _tmp28_, _tmp29_, _tmp30_);
		_tmp20_ = !_tmp31_;
	} else {
		_tmp20_ = FALSE;
	}
	_tmp32_ = _tmp20_;
	if (_tmp32_) {
		result = FALSE;
		_tile_unref0 (t1);
		_tile_unref0 (t0);
		return result;
	}
	_tmp35_ = t1;
	if (_tmp35_ != NULL) {
		guint _tmp36_;
		guint _tmp37_;
		guint _tmp38_;
		_tmp36_ = x0;
		_tmp37_ = puzzle_get_size (self);
		_tmp38_ = _tmp37_;
		_tmp34_ = _tmp36_ < _tmp38_;
	} else {
		_tmp34_ = FALSE;
	}
	_tmp39_ = _tmp34_;
	if (_tmp39_) {
		guint _tmp40_;
		guint _tmp41_;
		guint _tmp42_;
		guint _tmp43_;
		gboolean _tmp44_ = FALSE;
		_tmp40_ = x1;
		_tmp41_ = y1;
		_tmp42_ = x0;
		_tmp43_ = y0;
		_tmp44_ = puzzle_tile_fits (self, _tmp40_, _tmp41_, _tmp42_, _tmp43_);
		_tmp33_ = !_tmp44_;
	} else {
		_tmp33_ = FALSE;
	}
	_tmp45_ = _tmp33_;
	if (_tmp45_) {
		result = FALSE;
		_tile_unref0 (t1);
		_tile_unref0 (t0);
		return result;
	}
	result = TRUE;
	_tile_unref0 (t1);
	_tile_unref0 (t0);
	return result;
}


void puzzle_switch_tiles (Puzzle* self, guint x0, guint y0, guint x1, guint y1) {
	gboolean _tmp0_ = FALSE;
	guint _tmp1_;
	guint _tmp2_;
	gboolean _tmp5_;
	Tile** _tmp6_;
	gint _tmp6__length1;
	gint _tmp6__length2;
	guint _tmp7_;
	guint _tmp8_;
	Tile* _tmp9_;
	Tile* _tmp10_;
	Tile* t0;
	Tile** _tmp11_;
	gint _tmp11__length1;
	gint _tmp11__length2;
	guint _tmp12_;
	guint _tmp13_;
	Tile* _tmp14_;
	Tile* _tmp15_;
	Tile* t1;
	Tile** _tmp16_;
	gint _tmp16__length1;
	gint _tmp16__length2;
	guint _tmp17_;
	guint _tmp18_;
	Tile* _tmp19_;
	Tile* _tmp20_;
	Tile* _tmp21_;
	Tile** _tmp22_;
	gint _tmp22__length1;
	gint _tmp22__length2;
	guint _tmp23_;
	guint _tmp24_;
	Tile* _tmp25_;
	Tile* _tmp26_;
	Tile* _tmp27_;
	Tile* _tmp28_;
	Tile* _tmp32_;
	gboolean _tmp36_;
	gboolean _tmp37_;
	g_return_if_fail (self != NULL);
	_tmp1_ = x0;
	_tmp2_ = x1;
	if (_tmp1_ == _tmp2_) {
		guint _tmp3_;
		guint _tmp4_;
		_tmp3_ = y0;
		_tmp4_ = y1;
		_tmp0_ = _tmp3_ == _tmp4_;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp5_ = _tmp0_;
	if (_tmp5_) {
		return;
	}
	_tmp6_ = self->priv->board;
	_tmp6__length1 = self->priv->board_length1;
	_tmp6__length2 = self->priv->board_length2;
	_tmp7_ = x0;
	_tmp8_ = y0;
	_tmp9_ = _tmp6_[(_tmp7_ * _tmp6__length2) + _tmp8_];
	_tmp10_ = _tile_ref0 (_tmp9_);
	t0 = _tmp10_;
	_tmp11_ = self->priv->board;
	_tmp11__length1 = self->priv->board_length1;
	_tmp11__length2 = self->priv->board_length2;
	_tmp12_ = x1;
	_tmp13_ = y1;
	_tmp14_ = _tmp11_[(_tmp12_ * _tmp11__length2) + _tmp13_];
	_tmp15_ = _tile_ref0 (_tmp14_);
	t1 = _tmp15_;
	_tmp16_ = self->priv->board;
	_tmp16__length1 = self->priv->board_length1;
	_tmp16__length2 = self->priv->board_length2;
	_tmp17_ = x0;
	_tmp18_ = y0;
	_tmp19_ = t1;
	_tmp20_ = _tile_ref0 (_tmp19_);
	_tile_unref0 (_tmp16_[(_tmp17_ * _tmp16__length2) + _tmp18_]);
	_tmp16_[(_tmp17_ * _tmp16__length2) + _tmp18_] = _tmp20_;
	_tmp21_ = _tmp16_[(_tmp17_ * _tmp16__length2) + _tmp18_];
	_tmp22_ = self->priv->board;
	_tmp22__length1 = self->priv->board_length1;
	_tmp22__length2 = self->priv->board_length2;
	_tmp23_ = x1;
	_tmp24_ = y1;
	_tmp25_ = t0;
	_tmp26_ = _tile_ref0 (_tmp25_);
	_tile_unref0 (_tmp22_[(_tmp23_ * _tmp22__length2) + _tmp24_]);
	_tmp22_[(_tmp23_ * _tmp22__length2) + _tmp24_] = _tmp26_;
	_tmp27_ = _tmp22_[(_tmp23_ * _tmp22__length2) + _tmp24_];
	_tmp28_ = t0;
	if (_tmp28_ != NULL) {
		Tile* _tmp29_;
		guint _tmp30_;
		guint _tmp31_;
		_tmp29_ = t0;
		_tmp30_ = x1;
		_tmp31_ = y1;
		g_signal_emit_by_name (self, "tile-moved", _tmp29_, _tmp30_, _tmp31_);
	}
	_tmp32_ = t1;
	if (_tmp32_ != NULL) {
		Tile* _tmp33_;
		guint _tmp34_;
		guint _tmp35_;
		_tmp33_ = t1;
		_tmp34_ = x0;
		_tmp35_ = y0;
		g_signal_emit_by_name (self, "tile-moved", _tmp33_, _tmp34_, _tmp35_);
	}
	_tmp36_ = puzzle_get_is_solved (self);
	_tmp37_ = _tmp36_;
	if (_tmp37_) {
		g_signal_emit_by_name (self, "solved");
	}
	_tile_unref0 (t1);
	_tile_unref0 (t0);
}


void puzzle_move_up (Puzzle* self) {
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = puzzle_get_can_move_up (self);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		return;
	}
	{
		gint y;
		y = 1;
		{
			gboolean _tmp2_;
			_tmp2_ = TRUE;
			while (TRUE) {
				gboolean _tmp3_;
				gint _tmp5_;
				guint _tmp6_;
				guint _tmp7_;
				_tmp3_ = _tmp2_;
				if (!_tmp3_) {
					gint _tmp4_;
					_tmp4_ = y;
					y = _tmp4_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp5_ = y;
				_tmp6_ = puzzle_get_size (self);
				_tmp7_ = _tmp6_;
				if (!(((guint) _tmp5_) < _tmp7_)) {
					break;
				}
				{
					gint x;
					x = 0;
					{
						gboolean _tmp8_;
						_tmp8_ = TRUE;
						while (TRUE) {
							gboolean _tmp9_;
							gint _tmp11_;
							guint _tmp12_;
							guint _tmp13_;
							gint _tmp14_;
							gint _tmp15_;
							gint _tmp16_;
							gint _tmp17_;
							_tmp9_ = _tmp8_;
							if (!_tmp9_) {
								gint _tmp10_;
								_tmp10_ = x;
								x = _tmp10_ + 1;
							}
							_tmp8_ = FALSE;
							_tmp11_ = x;
							_tmp12_ = puzzle_get_size (self);
							_tmp13_ = _tmp12_;
							if (!(((guint) _tmp11_) < _tmp13_)) {
								break;
							}
							_tmp14_ = x;
							_tmp15_ = y;
							_tmp16_ = x;
							_tmp17_ = y;
							puzzle_switch_tiles (self, (guint) _tmp14_, (guint) _tmp15_, (guint) _tmp16_, (guint) (_tmp17_ - 1));
						}
					}
				}
			}
		}
	}
}


void puzzle_move_down (Puzzle* self) {
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = puzzle_get_can_move_down (self);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		return;
	}
	{
		guint _tmp2_;
		guint _tmp3_;
		gint y;
		_tmp2_ = puzzle_get_size (self);
		_tmp3_ = _tmp2_;
		y = ((gint) _tmp3_) - 2;
		{
			gboolean _tmp4_;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp5_;
				gint _tmp7_;
				_tmp5_ = _tmp4_;
				if (!_tmp5_) {
					gint _tmp6_;
					_tmp6_ = y;
					y = _tmp6_ - 1;
				}
				_tmp4_ = FALSE;
				_tmp7_ = y;
				if (!(_tmp7_ >= 0)) {
					break;
				}
				{
					gint x;
					x = 0;
					{
						gboolean _tmp8_;
						_tmp8_ = TRUE;
						while (TRUE) {
							gboolean _tmp9_;
							gint _tmp11_;
							guint _tmp12_;
							guint _tmp13_;
							gint _tmp14_;
							gint _tmp15_;
							gint _tmp16_;
							gint _tmp17_;
							_tmp9_ = _tmp8_;
							if (!_tmp9_) {
								gint _tmp10_;
								_tmp10_ = x;
								x = _tmp10_ + 1;
							}
							_tmp8_ = FALSE;
							_tmp11_ = x;
							_tmp12_ = puzzle_get_size (self);
							_tmp13_ = _tmp12_;
							if (!(((guint) _tmp11_) < _tmp13_)) {
								break;
							}
							_tmp14_ = x;
							_tmp15_ = y;
							_tmp16_ = x;
							_tmp17_ = y;
							puzzle_switch_tiles (self, (guint) _tmp14_, (guint) _tmp15_, (guint) _tmp16_, (guint) (_tmp17_ + 1));
						}
					}
				}
			}
		}
	}
}


void puzzle_move_left (Puzzle* self) {
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = puzzle_get_can_move_left (self);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		return;
	}
	{
		gint x;
		x = 1;
		{
			gboolean _tmp2_;
			_tmp2_ = TRUE;
			while (TRUE) {
				gboolean _tmp3_;
				gint _tmp5_;
				guint _tmp6_;
				guint _tmp7_;
				_tmp3_ = _tmp2_;
				if (!_tmp3_) {
					gint _tmp4_;
					_tmp4_ = x;
					x = _tmp4_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp5_ = x;
				_tmp6_ = puzzle_get_size (self);
				_tmp7_ = _tmp6_;
				if (!(((guint) _tmp5_) < _tmp7_)) {
					break;
				}
				{
					gint y;
					y = 0;
					{
						gboolean _tmp8_;
						_tmp8_ = TRUE;
						while (TRUE) {
							gboolean _tmp9_;
							gint _tmp11_;
							guint _tmp12_;
							guint _tmp13_;
							gint _tmp14_;
							gint _tmp15_;
							gint _tmp16_;
							gint _tmp17_;
							_tmp9_ = _tmp8_;
							if (!_tmp9_) {
								gint _tmp10_;
								_tmp10_ = y;
								y = _tmp10_ + 1;
							}
							_tmp8_ = FALSE;
							_tmp11_ = y;
							_tmp12_ = puzzle_get_size (self);
							_tmp13_ = _tmp12_;
							if (!(((guint) _tmp11_) < _tmp13_)) {
								break;
							}
							_tmp14_ = x;
							_tmp15_ = y;
							_tmp16_ = x;
							_tmp17_ = y;
							puzzle_switch_tiles (self, (guint) _tmp14_, (guint) _tmp15_, (guint) (_tmp16_ - 1), (guint) _tmp17_);
						}
					}
				}
			}
		}
	}
}


void puzzle_move_right (Puzzle* self) {
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = puzzle_get_can_move_right (self);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		return;
	}
	{
		guint _tmp2_;
		guint _tmp3_;
		gint x;
		_tmp2_ = puzzle_get_size (self);
		_tmp3_ = _tmp2_;
		x = ((gint) _tmp3_) - 2;
		{
			gboolean _tmp4_;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp5_;
				gint _tmp7_;
				_tmp5_ = _tmp4_;
				if (!_tmp5_) {
					gint _tmp6_;
					_tmp6_ = x;
					x = _tmp6_ - 1;
				}
				_tmp4_ = FALSE;
				_tmp7_ = x;
				if (!(_tmp7_ >= 0)) {
					break;
				}
				{
					gint y;
					y = 0;
					{
						gboolean _tmp8_;
						_tmp8_ = TRUE;
						while (TRUE) {
							gboolean _tmp9_;
							gint _tmp11_;
							guint _tmp12_;
							guint _tmp13_;
							gint _tmp14_;
							gint _tmp15_;
							gint _tmp16_;
							gint _tmp17_;
							_tmp9_ = _tmp8_;
							if (!_tmp9_) {
								gint _tmp10_;
								_tmp10_ = y;
								y = _tmp10_ + 1;
							}
							_tmp8_ = FALSE;
							_tmp11_ = y;
							_tmp12_ = puzzle_get_size (self);
							_tmp13_ = _tmp12_;
							if (!(((guint) _tmp11_) < _tmp13_)) {
								break;
							}
							_tmp14_ = x;
							_tmp15_ = y;
							_tmp16_ = x;
							_tmp17_ = y;
							puzzle_switch_tiles (self, (guint) _tmp14_, (guint) _tmp15_, (guint) (_tmp16_ + 1), (guint) _tmp17_);
						}
					}
				}
			}
		}
	}
}


void puzzle_solve (Puzzle* self) {
	GList* wrong_tiles;
	GList* _tmp34_;
	g_return_if_fail (self != NULL);
	wrong_tiles = NULL;
	{
		gint x;
		x = 0;
		{
			gboolean _tmp0_;
			_tmp0_ = TRUE;
			while (TRUE) {
				gboolean _tmp1_;
				gint _tmp3_;
				guint _tmp4_;
				guint _tmp5_;
				_tmp1_ = _tmp0_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = x;
					x = _tmp2_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp3_ = x;
				_tmp4_ = puzzle_get_size (self);
				_tmp5_ = _tmp4_;
				if (!(((guint) _tmp3_) < (_tmp5_ * 2))) {
					break;
				}
				{
					gint y;
					y = 0;
					{
						gboolean _tmp6_;
						_tmp6_ = TRUE;
						while (TRUE) {
							gboolean _tmp7_;
							gint _tmp9_;
							guint _tmp10_;
							guint _tmp11_;
							Tile** _tmp12_;
							gint _tmp12__length1;
							gint _tmp12__length2;
							gint _tmp13_;
							gint _tmp14_;
							Tile* _tmp15_;
							Tile* _tmp16_;
							Tile* tile;
							gboolean _tmp17_ = FALSE;
							Tile* _tmp18_;
							gboolean _tmp27_;
							Tile** _tmp30_;
							gint _tmp30__length1;
							gint _tmp30__length2;
							gint _tmp31_;
							gint _tmp32_;
							Tile* _tmp33_;
							_tmp7_ = _tmp6_;
							if (!_tmp7_) {
								gint _tmp8_;
								_tmp8_ = y;
								y = _tmp8_ + 1;
							}
							_tmp6_ = FALSE;
							_tmp9_ = y;
							_tmp10_ = puzzle_get_size (self);
							_tmp11_ = _tmp10_;
							if (!(((guint) _tmp9_) < _tmp11_)) {
								break;
							}
							_tmp12_ = self->priv->board;
							_tmp12__length1 = self->priv->board_length1;
							_tmp12__length2 = self->priv->board_length2;
							_tmp13_ = x;
							_tmp14_ = y;
							_tmp15_ = _tmp12_[(_tmp13_ * _tmp12__length2) + _tmp14_];
							_tmp16_ = _tile_ref0 (_tmp15_);
							tile = _tmp16_;
							_tmp18_ = tile;
							if (_tmp18_ != NULL) {
								gboolean _tmp19_ = FALSE;
								Tile* _tmp20_;
								guint _tmp21_;
								gint _tmp22_;
								gboolean _tmp26_;
								_tmp20_ = tile;
								_tmp21_ = _tmp20_->x;
								_tmp22_ = x;
								if (_tmp21_ != ((guint) _tmp22_)) {
									_tmp19_ = TRUE;
								} else {
									Tile* _tmp23_;
									guint _tmp24_;
									gint _tmp25_;
									_tmp23_ = tile;
									_tmp24_ = _tmp23_->y;
									_tmp25_ = y;
									_tmp19_ = _tmp24_ != ((guint) _tmp25_);
								}
								_tmp26_ = _tmp19_;
								_tmp17_ = _tmp26_;
							} else {
								_tmp17_ = FALSE;
							}
							_tmp27_ = _tmp17_;
							if (_tmp27_) {
								Tile* _tmp28_;
								Tile* _tmp29_;
								_tmp28_ = tile;
								_tmp29_ = _tile_ref0 (_tmp28_);
								wrong_tiles = g_list_append (wrong_tiles, _tmp29_);
							}
							_tmp30_ = self->priv->board;
							_tmp30__length1 = self->priv->board_length1;
							_tmp30__length2 = self->priv->board_length2;
							_tmp31_ = x;
							_tmp32_ = y;
							_tile_unref0 (_tmp30_[(_tmp31_ * _tmp30__length2) + _tmp32_]);
							_tmp30_[(_tmp31_ * _tmp30__length2) + _tmp32_] = NULL;
							_tmp33_ = _tmp30_[(_tmp31_ * _tmp30__length2) + _tmp32_];
							_tile_unref0 (tile);
						}
					}
				}
			}
		}
	}
	_tmp34_ = wrong_tiles;
	{
		GList* tile_collection = NULL;
		GList* tile_it = NULL;
		tile_collection = _tmp34_;
		for (tile_it = tile_collection; tile_it != NULL; tile_it = tile_it->next) {
			Tile* _tmp35_;
			Tile* tile = NULL;
			_tmp35_ = _tile_ref0 ((Tile*) tile_it->data);
			tile = _tmp35_;
			{
				Tile** _tmp36_;
				gint _tmp36__length1;
				gint _tmp36__length2;
				Tile* _tmp37_;
				guint _tmp38_;
				Tile* _tmp39_;
				guint _tmp40_;
				Tile* _tmp41_;
				Tile* _tmp42_;
				Tile* _tmp43_;
				Tile* _tmp44_;
				Tile* _tmp45_;
				guint _tmp46_;
				Tile* _tmp47_;
				guint _tmp48_;
				_tmp36_ = self->priv->board;
				_tmp36__length1 = self->priv->board_length1;
				_tmp36__length2 = self->priv->board_length2;
				_tmp37_ = tile;
				_tmp38_ = _tmp37_->x;
				_tmp39_ = tile;
				_tmp40_ = _tmp39_->y;
				_tmp41_ = tile;
				_tmp42_ = _tile_ref0 (_tmp41_);
				_tile_unref0 (_tmp36_[(_tmp38_ * _tmp36__length2) + _tmp40_]);
				_tmp36_[(_tmp38_ * _tmp36__length2) + _tmp40_] = _tmp42_;
				_tmp43_ = _tmp36_[(_tmp38_ * _tmp36__length2) + _tmp40_];
				_tmp44_ = tile;
				_tmp45_ = tile;
				_tmp46_ = _tmp45_->x;
				_tmp47_ = tile;
				_tmp48_ = _tmp47_->y;
				g_signal_emit_by_name (self, "tile-moved", _tmp44_, _tmp46_, _tmp48_);
				_tile_unref0 (tile);
			}
		}
	}
	__g_list_free__tile_unref0_0 (wrong_tiles);
}


guint puzzle_get_size (Puzzle* self) {
	guint result;
	guint _tmp0_;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = self->priv->_size;
	result = _tmp0_;
	return result;
}


gboolean puzzle_get_is_solved (Puzzle* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	{
		gint x;
		x = 0;
		{
			gboolean _tmp0_;
			_tmp0_ = TRUE;
			while (TRUE) {
				gboolean _tmp1_;
				gint _tmp3_;
				guint _tmp4_;
				guint _tmp5_;
				_tmp1_ = _tmp0_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = x;
					x = _tmp2_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp3_ = x;
				_tmp4_ = puzzle_get_size (self);
				_tmp5_ = _tmp4_;
				if (!(((guint) _tmp3_) < _tmp5_)) {
					break;
				}
				{
					gint y;
					y = 0;
					{
						gboolean _tmp6_;
						_tmp6_ = TRUE;
						while (TRUE) {
							gboolean _tmp7_;
							gint _tmp9_;
							guint _tmp10_;
							guint _tmp11_;
							Tile** _tmp12_;
							gint _tmp12__length1;
							gint _tmp12__length2;
							gint _tmp13_;
							gint _tmp14_;
							Tile* _tmp15_;
							Tile* _tmp16_;
							Tile* tile;
							Tile* _tmp17_;
							_tmp7_ = _tmp6_;
							if (!_tmp7_) {
								gint _tmp8_;
								_tmp8_ = y;
								y = _tmp8_ + 1;
							}
							_tmp6_ = FALSE;
							_tmp9_ = y;
							_tmp10_ = puzzle_get_size (self);
							_tmp11_ = _tmp10_;
							if (!(((guint) _tmp9_) < _tmp11_)) {
								break;
							}
							_tmp12_ = self->priv->board;
							_tmp12__length1 = self->priv->board_length1;
							_tmp12__length2 = self->priv->board_length2;
							_tmp13_ = x;
							_tmp14_ = y;
							_tmp15_ = _tmp12_[(_tmp13_ * _tmp12__length2) + _tmp14_];
							_tmp16_ = _tile_ref0 (_tmp15_);
							tile = _tmp16_;
							_tmp17_ = tile;
							if (_tmp17_ == NULL) {
								result = FALSE;
								_tile_unref0 (tile);
								return result;
							}
							_tile_unref0 (tile);
						}
					}
				}
			}
		}
	}
	result = TRUE;
	return result;
}


gboolean puzzle_get_can_move_up (Puzzle* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	{
		gint x;
		x = 0;
		{
			gboolean _tmp0_;
			_tmp0_ = TRUE;
			while (TRUE) {
				gboolean _tmp1_;
				gint _tmp3_;
				guint _tmp4_;
				guint _tmp5_;
				Tile** _tmp6_;
				gint _tmp6__length1;
				gint _tmp6__length2;
				gint _tmp7_;
				Tile* _tmp8_;
				_tmp1_ = _tmp0_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = x;
					x = _tmp2_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp3_ = x;
				_tmp4_ = puzzle_get_size (self);
				_tmp5_ = _tmp4_;
				if (!(((guint) _tmp3_) < _tmp5_)) {
					break;
				}
				_tmp6_ = self->priv->board;
				_tmp6__length1 = self->priv->board_length1;
				_tmp6__length2 = self->priv->board_length2;
				_tmp7_ = x;
				_tmp8_ = _tmp6_[(_tmp7_ * _tmp6__length2) + 0];
				if (_tmp8_ != NULL) {
					result = FALSE;
					return result;
				}
			}
		}
	}
	result = TRUE;
	return result;
}


gboolean puzzle_get_can_move_down (Puzzle* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	{
		gint x;
		x = 0;
		{
			gboolean _tmp0_;
			_tmp0_ = TRUE;
			while (TRUE) {
				gboolean _tmp1_;
				gint _tmp3_;
				guint _tmp4_;
				guint _tmp5_;
				Tile** _tmp6_;
				gint _tmp6__length1;
				gint _tmp6__length2;
				gint _tmp7_;
				guint _tmp8_;
				guint _tmp9_;
				Tile* _tmp10_;
				_tmp1_ = _tmp0_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = x;
					x = _tmp2_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp3_ = x;
				_tmp4_ = puzzle_get_size (self);
				_tmp5_ = _tmp4_;
				if (!(((guint) _tmp3_) < _tmp5_)) {
					break;
				}
				_tmp6_ = self->priv->board;
				_tmp6__length1 = self->priv->board_length1;
				_tmp6__length2 = self->priv->board_length2;
				_tmp7_ = x;
				_tmp8_ = puzzle_get_size (self);
				_tmp9_ = _tmp8_;
				_tmp10_ = _tmp6_[(_tmp7_ * _tmp6__length2) + (_tmp9_ - 1)];
				if (_tmp10_ != NULL) {
					result = FALSE;
					return result;
				}
			}
		}
	}
	result = TRUE;
	return result;
}


gboolean puzzle_get_can_move_left (Puzzle* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	{
		gint y;
		y = 0;
		{
			gboolean _tmp0_;
			_tmp0_ = TRUE;
			while (TRUE) {
				gboolean _tmp1_;
				gint _tmp3_;
				guint _tmp4_;
				guint _tmp5_;
				Tile** _tmp6_;
				gint _tmp6__length1;
				gint _tmp6__length2;
				gint _tmp7_;
				Tile* _tmp8_;
				_tmp1_ = _tmp0_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = y;
					y = _tmp2_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp3_ = y;
				_tmp4_ = puzzle_get_size (self);
				_tmp5_ = _tmp4_;
				if (!(((guint) _tmp3_) < _tmp5_)) {
					break;
				}
				_tmp6_ = self->priv->board;
				_tmp6__length1 = self->priv->board_length1;
				_tmp6__length2 = self->priv->board_length2;
				_tmp7_ = y;
				_tmp8_ = _tmp6_[(0 * _tmp6__length2) + _tmp7_];
				if (_tmp8_ != NULL) {
					result = FALSE;
					return result;
				}
			}
		}
	}
	result = TRUE;
	return result;
}


gboolean puzzle_get_can_move_right (Puzzle* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	{
		gint y;
		y = 0;
		{
			gboolean _tmp0_;
			_tmp0_ = TRUE;
			while (TRUE) {
				gboolean _tmp1_;
				gint _tmp3_;
				guint _tmp4_;
				guint _tmp5_;
				Tile** _tmp6_;
				gint _tmp6__length1;
				gint _tmp6__length2;
				guint _tmp7_;
				guint _tmp8_;
				gint _tmp9_;
				Tile* _tmp10_;
				_tmp1_ = _tmp0_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = y;
					y = _tmp2_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp3_ = y;
				_tmp4_ = puzzle_get_size (self);
				_tmp5_ = _tmp4_;
				if (!(((guint) _tmp3_) < _tmp5_)) {
					break;
				}
				_tmp6_ = self->priv->board;
				_tmp6__length1 = self->priv->board_length1;
				_tmp6__length2 = self->priv->board_length2;
				_tmp7_ = puzzle_get_size (self);
				_tmp8_ = _tmp7_;
				_tmp9_ = y;
				_tmp10_ = _tmp6_[((_tmp8_ - 1) * _tmp6__length2) + _tmp9_];
				if (_tmp10_ != NULL) {
					result = FALSE;
					return result;
				}
			}
		}
	}
	result = TRUE;
	return result;
}


static void g_cclosure_user_marshal_VOID__TILE_UINT_UINT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__TILE_UINT_UINT) (gpointer data1, gpointer arg_1, guint arg_2, guint arg_3, gpointer data2);
	register GMarshalFunc_VOID__TILE_UINT_UINT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 4);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__TILE_UINT_UINT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, value_get_tile (param_values + 1), g_value_get_uint (param_values + 2), g_value_get_uint (param_values + 3), data2);
}


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


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


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


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


static gchar* value_puzzle_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		Puzzle* 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 = puzzle_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* value_puzzle_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	Puzzle** 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 = puzzle_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* param_spec_puzzle (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	ParamSpecPuzzle* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_PUZZLE), 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 value_get_puzzle (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_PUZZLE), NULL);
	return value->data[0].v_pointer;
}


void value_set_puzzle (GValue* value, gpointer v_object) {
	Puzzle* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_PUZZLE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_PUZZLE));
		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;
		puzzle_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		puzzle_unref (old);
	}
}


void value_take_puzzle (GValue* value, gpointer v_object) {
	Puzzle* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_PUZZLE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_PUZZLE));
		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) {
		puzzle_unref (old);
	}
}


static void puzzle_class_init (PuzzleClass * klass) {
	puzzle_parent_class = g_type_class_peek_parent (klass);
	PUZZLE_CLASS (klass)->finalize = puzzle_finalize;
	g_type_class_add_private (klass, sizeof (PuzzlePrivate));
	g_signal_new ("tile_moved", TYPE_PUZZLE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__TILE_UINT_UINT, G_TYPE_NONE, 3, TYPE_TILE, G_TYPE_UINT, G_TYPE_UINT);
	g_signal_new ("solved", TYPE_PUZZLE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void puzzle_instance_init (Puzzle * self) {
	self->priv = PUZZLE_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void puzzle_finalize (Puzzle* obj) {
	Puzzle * self;
	self = PUZZLE (obj);
	self->priv->board = (_vala_array_free (self->priv->board, self->priv->board_length1 * self->priv->board_length2, (GDestroyNotify) tile_unref), NULL);
}


GType puzzle_get_type (void) {
	static volatile gsize puzzle_type_id__volatile = 0;
	if (g_once_init_enter (&puzzle_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { value_puzzle_init, value_puzzle_free_value, value_puzzle_copy_value, value_puzzle_peek_pointer, "p", value_puzzle_collect_value, "p", value_puzzle_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (PuzzleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) puzzle_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Puzzle), 0, (GInstanceInitFunc) puzzle_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 puzzle_type_id;
		puzzle_type_id = g_type_register_fundamental (g_type_fundamental_next (), "Puzzle", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&puzzle_type_id__volatile, puzzle_type_id);
	}
	return puzzle_type_id__volatile;
}


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


void puzzle_unref (gpointer instance) {
	Puzzle* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		PUZZLE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}


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



