/* gnome-tetravex-cli.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from gnome-tetravex-cli.vala, do not modify */

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-

   This file is part of GNOME Tetravex.

   Copyright (C) 2019 Arnaud Bonatti

   GNOME Tetravex is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 2 of the License, or
   (at your option) any later version.

   GNOME Tetravex is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along
   with this GNOME Tetravex.  If not, see <https://www.gnu.org/licenses/>.
*/

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

#define TETRAVEX_CLI_KEY_GRID_SIZE "grid-size"
#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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_TETRAVEX_CLI (tetravex_cli_get_type ())
#define TETRAVEX_CLI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TETRAVEX_CLI, TetravexCli))
#define TETRAVEX_CLI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TETRAVEX_CLI, TetravexCliClass))
#define IS_TETRAVEX_CLI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TETRAVEX_CLI))
#define IS_TETRAVEX_CLI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TETRAVEX_CLI))
#define TETRAVEX_CLI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TETRAVEX_CLI, TetravexCliClass))

typedef struct _TetravexCli TetravexCli;
typedef struct _TetravexCliClass TetravexCliClass;
typedef struct _TetravexCliPrivate TetravexCliPrivate;

#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;
enum  {
	TETRAVEX_CLI_0_PROPERTY,
	TETRAVEX_CLI_NUM_PROPERTIES
};
static GParamSpec* tetravex_cli_properties[TETRAVEX_CLI_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _TetravexCli {
	GApplication parent_instance;
	TetravexCliPrivate * priv;
};

struct _TetravexCliClass {
	GApplicationClass parent_class;
};

struct _TetravexCliPrivate {
	gchar* nothing_text;
	gchar* help_text;
	GVariant* saved_game;
	gboolean can_restore;
	GSettings* settings;
	Puzzle* puzzle;
};

static gint TetravexCli_private_offset;
static gpointer tetravex_cli_parent_class = NULL;
static gint tetravex_cli_colors;
static gint tetravex_cli_game_size;
static gchar** tetravex_cli_remaining;
static gint tetravex_cli_remaining_length1;
static gint tetravex_cli_game_size = G_MININT;
static gint tetravex_cli_colors = 10;
static gchar* tetravex_cli_cli;
static gchar* tetravex_cli_cli = NULL;
static gchar** tetravex_cli_remaining = NULL;
static gint tetravex_cli_remaining_length1 = 0;
static gint _tetravex_cli_remaining_size_ = 0;

VALA_EXTERN GType tetravex_cli_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TetravexCli, g_object_unref)
VALA_EXTERN GType puzzle_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Puzzle, g_object_unref)
static gint tetravex_cli_main (gchar** args,
                        gint args_length1);
static TetravexCli* tetravex_cli_new (void);
static TetravexCli* tetravex_cli_construct (GType object_type);
static gint tetravex_cli_real_handle_local_options (GApplication* base,
                                             GVariantDict* options);
VALA_EXTERN gint cli_play_cli (const gchar* cli,
                   const gchar* schema_name,
                   GSettings** settings,
                   GVariant** saved_game,
                   gboolean* can_restore,
                   Puzzle** puzzle,
                   gint* colors,
                   gint* game_size);
static void tetravex_cli_finalize (GObject * obj);
static GType tetravex_cli_get_type_once (void);

static const GOptionEntry TETRAVEX_CLI_option_entries[5] = {{"colors", 'c', (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_INT, &tetravex_cli_colors, N_ ("Set number of colors (2-10)"), N_ ("NUMBER")}, {"size", 's', (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_INT, &tetravex_cli_game_size, N_ ("Set size of board (2-6)"), N_ ("SIZE")}, {"version", 'v', (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, N_ ("Print release version and exit"), NULL}, {G_OPTION_REMAINING, (gchar) 0, (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING_ARRAY, &tetravex_cli_remaining, "args", NULL}, {0}};

static inline gpointer
tetravex_cli_get_instance_private (TetravexCli* self)
{
	return G_STRUCT_MEMBER_P (self, TetravexCli_private_offset);
}

static gint
tetravex_cli_main (gchar** args,
                   gint args_length1)
{
	TetravexCli* app = NULL;
	TetravexCli* _tmp0_;
	gint result;
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	_tmp0_ = tetravex_cli_new ();
	app = _tmp0_;
	result = g_application_run ((GApplication*) app, (gint) args_length1, args);
	_g_object_unref0 (app);
	return result;
}

int
main (int argc,
      char ** argv)
{
	return tetravex_cli_main (argv, argc);
}

static TetravexCli*
tetravex_cli_construct (GType object_type)
{
	TetravexCli * self = NULL;
	const gchar* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	const gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	gchar* _tmp49_;
	gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	gchar* _tmp53_;
	gchar* _tmp54_;
	gchar* _tmp55_;
	gchar* _tmp56_;
	gchar* _tmp57_;
	gchar* _tmp58_;
	gchar* _tmp59_;
	gchar* _tmp60_;
	gchar* _tmp61_;
	gchar* _tmp62_;
	gchar* _tmp63_;
	gchar* _tmp64_;
	gchar* _tmp65_;
	gchar* _tmp66_;
	gchar* _tmp67_;
	gchar* _tmp68_;
	gchar* _tmp69_;
	gchar* _tmp70_;
	gchar* _tmp71_;
	gchar* _tmp72_;
	gchar* _tmp73_;
	gchar* _tmp74_;
	gchar* _tmp75_;
	gchar* _tmp76_;
	gchar* _tmp77_;
	gchar* _tmp78_;
	gchar* _tmp79_;
	gchar* _tmp80_;
	gchar* _tmp81_;
	gchar* _tmp82_;
	gchar* _tmp83_;
	gchar* _tmp84_;
	gchar* _tmp85_;
	gchar* _tmp86_;
	gchar* _tmp87_;
	gchar* _tmp88_;
	gchar* _tmp89_;
	gchar* _tmp90_;
	gchar* _tmp91_;
	gchar* _tmp92_;
	gchar* _tmp93_;
	gchar* _tmp94_;
	gchar* _tmp95_;
	gchar* _tmp96_;
	gchar* _tmp97_;
	gchar* _tmp98_;
	gchar* _tmp99_;
	gchar* _tmp100_;
	gchar* _tmp101_;
	gchar* _tmp102_;
	gchar* _tmp103_;
	gchar* _tmp104_;
	gchar* _tmp105_;
	gchar* _tmp106_;
	gchar* _tmp107_;
	gchar* _tmp108_;
	gchar* _tmp109_;
	gchar* _tmp110_;
	gchar* _tmp111_;
	gchar* _tmp112_;
	gchar* _tmp113_;
	gchar* _tmp114_;
	gchar* _tmp115_;
	gchar* _tmp116_;
	gchar* _tmp117_;
	gchar* _tmp118_;
	gchar* _tmp119_;
	gchar* _tmp120_;
	const gchar* _tmp121_;
	gchar* _tmp122_;
	gchar* _tmp123_;
	self = (TetravexCli*) g_object_new (object_type, "application-id", "org.gnome.TetravexCli", "flags", G_APPLICATION_FLAGS_NONE, NULL);
	_tmp0_ = self->priv->nothing_text;
	_tmp1_ = strlen (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ > 13) {
		gchar* _tmp3_;
		_tmp3_ = g_strdup ("()");
		_g_free0 (self->priv->nothing_text);
		self->priv->nothing_text = _tmp3_;
	}
	_tmp4_ = self->priv->nothing_text;
	_tmp5_ = g_strconcat ("  ", _tmp4_, NULL);
	_g_free0 (self->priv->nothing_text);
	self->priv->nothing_text = _tmp5_;
	{
		gint x = 0;
		const gchar* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		_tmp6_ = self->priv->nothing_text;
		_tmp7_ = strlen (_tmp6_);
		_tmp8_ = _tmp7_;
		x = _tmp8_;
		{
			gboolean _tmp9_ = FALSE;
			_tmp9_ = TRUE;
			while (TRUE) {
				const gchar* _tmp11_;
				gchar* _tmp12_;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = x;
					x = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				if (!(x < 16)) {
					break;
				}
				_tmp11_ = self->priv->nothing_text;
				_tmp12_ = g_strconcat (_tmp11_, " ", NULL);
				_g_free0 (self->priv->nothing_text);
				self->priv->nothing_text = _tmp12_;
			}
		}
	}
	_tmp13_ = g_strconcat ("" "\n" "  A1b2          ", _ ("Invert two tiles, the one in A1, and the one in b2."), NULL);
	_tmp14_ = _tmp13_;
	_tmp15_ = g_strconcat (_tmp14_, "\n", NULL);
	_tmp16_ = _tmp15_;
	_tmp17_ = g_strconcat (_tmp16_, "                ", NULL);
	_tmp18_ = _tmp17_;
	_tmp19_ = g_strconcat (_tmp18_, _ ("An uppercase targets a tile from the initial board."), NULL);
	_tmp20_ = _tmp19_;
	_tmp21_ = g_strconcat (_tmp20_, "\n", NULL);
	_tmp22_ = _tmp21_;
	_tmp23_ = g_strconcat (_tmp22_, "                ", NULL);
	_tmp24_ = _tmp23_;
	_tmp25_ = g_strconcat (_tmp24_, _ ("A lowercase targets a tile in the left/final board."), NULL);
	_tmp26_ = _tmp25_;
	_tmp27_ = g_strconcat (_tmp26_, "\n", NULL);
	_tmp28_ = _tmp27_;
	_tmp29_ = g_strconcat (_tmp28_, "                ", NULL);
	_tmp30_ = _tmp29_;
	_tmp31_ = g_strconcat (_tmp30_, _ ("Digits specify the rows of the two tiles to invert."), NULL);
	_tmp32_ = _tmp31_;
	_tmp33_ = g_strconcat (_tmp32_, "\n", NULL);
	_tmp34_ = _tmp33_;
	_tmp35_ = g_strconcat (_tmp34_, "\n", NULL);
	_tmp36_ = _tmp35_;
	_tmp37_ = self->priv->nothing_text;
	_tmp38_ = g_strconcat (_tmp36_, _tmp37_, NULL);
	_tmp39_ = _tmp38_;
	_tmp40_ = g_strconcat (_tmp39_, _ ("Show the current puzzle. Alias: “status” or “show”."), NULL);
	_tmp41_ = _tmp40_;
	_tmp42_ = g_strconcat (_tmp41_, "\n", NULL);
	_tmp43_ = _tmp42_;
	_tmp44_ = g_strconcat (_tmp43_, "  new           ", NULL);
	_tmp45_ = _tmp44_;
	_tmp46_ = g_strconcat (_tmp45_, _ ("Create a new puzzle; for changing size, use --size."), NULL);
	_tmp47_ = _tmp46_;
	_tmp48_ = g_strconcat (_tmp47_, "\n", NULL);
	_tmp49_ = _tmp48_;
	_tmp50_ = g_strconcat (_tmp49_, "  solve         ", NULL);
	_tmp51_ = _tmp50_;
	_tmp52_ = g_strconcat (_tmp51_, _ ("Give up with current puzzle, and view the solution."), NULL);
	_tmp53_ = _tmp52_;
	_tmp54_ = g_strconcat (_tmp53_, "\n", NULL);
	_tmp55_ = _tmp54_;
	_tmp56_ = g_strconcat (_tmp55_, "\n", NULL);
	_tmp57_ = _tmp56_;
	_tmp58_ = g_strconcat (_tmp57_, "  finish        ", NULL);
	_tmp59_ = _tmp58_;
	_tmp60_ = g_strconcat (_tmp59_, _ ("Finish current puzzle, automatically. Alias: “end”."), NULL);
	_tmp61_ = _tmp60_;
	_tmp62_ = g_strconcat (_tmp61_, "\n", NULL);
	_tmp63_ = _tmp62_;
	_tmp64_ = g_strconcat (_tmp63_, "                ", NULL);
	_tmp65_ = _tmp64_;
	_tmp66_ = g_strconcat (_tmp65_, _ ("Works for puzzles solved right or if one tile left."), NULL);
	_tmp67_ = _tmp66_;
	_tmp68_ = g_strconcat (_tmp67_, "\n", NULL);
	_tmp69_ = _tmp68_;
	_tmp70_ = g_strconcat (_tmp69_, "\n", NULL);
	_tmp71_ = _tmp70_;
	_tmp72_ = g_strconcat (_tmp71_, "  up            ", NULL);
	_tmp73_ = _tmp72_;
	_tmp74_ = g_strconcat (_tmp73_, _ ("Move all left-board tiles up by one."), NULL);
	_tmp75_ = _tmp74_;
	_tmp76_ = g_strconcat (_tmp75_, "\n", NULL);
	_tmp77_ = _tmp76_;
	_tmp78_ = g_strconcat (_tmp77_, "  down          ", NULL);
	_tmp79_ = _tmp78_;
	_tmp80_ = g_strconcat (_tmp79_, _ ("Move all left-board tiles down by one."), NULL);
	_tmp81_ = _tmp80_;
	_tmp82_ = g_strconcat (_tmp81_, "\n", NULL);
	_tmp83_ = _tmp82_;
	_tmp84_ = g_strconcat (_tmp83_, "  left          ", NULL);
	_tmp85_ = _tmp84_;
	_tmp86_ = g_strconcat (_tmp85_, _ ("Move all left-board tiles left by one."), NULL);
	_tmp87_ = _tmp86_;
	_tmp88_ = g_strconcat (_tmp87_, "\n", NULL);
	_tmp89_ = _tmp88_;
	_tmp90_ = g_strconcat (_tmp89_, "  right         ", NULL);
	_tmp91_ = _tmp90_;
	_tmp92_ = g_strconcat (_tmp91_, _ ("Move all left-board tiles right by one."), NULL);
	_tmp93_ = _tmp92_;
	_tmp94_ = g_strconcat (_tmp93_, "\n", NULL);
	_tmp95_ = _tmp94_;
	_tmp96_ = g_strconcat (_tmp95_, "\n", NULL);
	_tmp97_ = _tmp96_;
	_tmp98_ = g_strconcat (_tmp97_, "  r-up          ", NULL);
	_tmp99_ = _tmp98_;
	_tmp100_ = g_strconcat (_tmp99_, _ ("Move all right-board tiles up by one."), NULL);
	_tmp101_ = _tmp100_;
	_tmp102_ = g_strconcat (_tmp101_, "\n", NULL);
	_tmp103_ = _tmp102_;
	_tmp104_ = g_strconcat (_tmp103_, "  r-down        ", NULL);
	_tmp105_ = _tmp104_;
	_tmp106_ = g_strconcat (_tmp105_, _ ("Move all right-board tiles down by one."), NULL);
	_tmp107_ = _tmp106_;
	_tmp108_ = g_strconcat (_tmp107_, "\n", NULL);
	_tmp109_ = _tmp108_;
	_tmp110_ = g_strconcat (_tmp109_, "  r-left        ", NULL);
	_tmp111_ = _tmp110_;
	_tmp112_ = g_strconcat (_tmp111_, _ ("Move all right-board tiles left by one."), NULL);
	_tmp113_ = _tmp112_;
	_tmp114_ = g_strconcat (_tmp113_, "\n", NULL);
	_tmp115_ = _tmp114_;
	_tmp116_ = g_strconcat (_tmp115_, "  r-right       ", NULL);
	_tmp117_ = _tmp116_;
	_tmp118_ = g_strconcat (_tmp117_, _ ("Move all right-board tiles right by one."), NULL);
	_tmp119_ = _tmp118_;
	_tmp120_ = g_strconcat (_tmp119_, "\n", NULL);
	_g_free0 (self->priv->help_text);
	self->priv->help_text = _tmp120_;
	_g_free0 (_tmp119_);
	_g_free0 (_tmp117_);
	_g_free0 (_tmp115_);
	_g_free0 (_tmp113_);
	_g_free0 (_tmp111_);
	_g_free0 (_tmp109_);
	_g_free0 (_tmp107_);
	_g_free0 (_tmp105_);
	_g_free0 (_tmp103_);
	_g_free0 (_tmp101_);
	_g_free0 (_tmp99_);
	_g_free0 (_tmp97_);
	_g_free0 (_tmp95_);
	_g_free0 (_tmp93_);
	_g_free0 (_tmp91_);
	_g_free0 (_tmp89_);
	_g_free0 (_tmp87_);
	_g_free0 (_tmp85_);
	_g_free0 (_tmp83_);
	_g_free0 (_tmp81_);
	_g_free0 (_tmp79_);
	_g_free0 (_tmp77_);
	_g_free0 (_tmp75_);
	_g_free0 (_tmp73_);
	_g_free0 (_tmp71_);
	_g_free0 (_tmp69_);
	_g_free0 (_tmp67_);
	_g_free0 (_tmp65_);
	_g_free0 (_tmp63_);
	_g_free0 (_tmp61_);
	_g_free0 (_tmp59_);
	_g_free0 (_tmp57_);
	_g_free0 (_tmp55_);
	_g_free0 (_tmp53_);
	_g_free0 (_tmp51_);
	_g_free0 (_tmp49_);
	_g_free0 (_tmp47_);
	_g_free0 (_tmp45_);
	_g_free0 (_tmp43_);
	_g_free0 (_tmp41_);
	_g_free0 (_tmp39_);
	_g_free0 (_tmp36_);
	_g_free0 (_tmp34_);
	_g_free0 (_tmp32_);
	_g_free0 (_tmp30_);
	_g_free0 (_tmp28_);
	_g_free0 (_tmp26_);
	_g_free0 (_tmp24_);
	_g_free0 (_tmp22_);
	_g_free0 (_tmp20_);
	_g_free0 (_tmp18_);
	_g_free0 (_tmp16_);
	_g_free0 (_tmp14_);
	g_application_set_option_context_parameter_string ((GApplication*) self, _ ("[COMMAND]"));
	_tmp121_ = self->priv->help_text;
	_tmp122_ = g_strconcat (_ ("Available commands:"), _tmp121_, NULL);
	_tmp123_ = _tmp122_;
	g_application_set_option_context_description ((GApplication*) self, _tmp123_);
	_g_free0 (_tmp123_);
	g_application_add_main_option_entries ((GApplication*) self, TETRAVEX_CLI_option_entries);
	return self;
}

static TetravexCli*
tetravex_cli_new (void)
{
	return tetravex_cli_construct (TYPE_TETRAVEX_CLI);
}

static gint
tetravex_cli_real_handle_local_options (GApplication* base,
                                        GVariantDict* options)
{
	TetravexCli * self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp12_ = FALSE;
	gchar** _tmp16_;
	gint _tmp16__length1;
	const gchar* _tmp17_;
	const gchar* _tmp21_ = NULL;
	gchar** _tmp22_;
	gint _tmp22__length1;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	gboolean _tmp25_ = FALSE;
	const gchar* _tmp26_;
	const gchar* _tmp33_;
	GSettings* _tmp34_ = NULL;
	GVariant* _tmp35_ = NULL;
	gboolean _tmp36_ = FALSE;
	Puzzle* _tmp37_ = NULL;
	gint _tmp38_;
	gint result;
	self = (TetravexCli*) base;
	g_return_val_if_fail (options != NULL, 0);
	if (g_variant_dict_contains (options, "version")) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp1_ = FALSE;
		gchar** _tmp2_;
		gint _tmp2__length1;
		const gchar* _tmp3_;
		_tmp2_ = tetravex_cli_remaining;
		_tmp2__length1 = tetravex_cli_remaining_length1;
		_tmp3_ = _tmp2_[0];
		if (_tmp3_ != NULL) {
			gchar** _tmp4_;
			gint _tmp4__length1;
			const gchar* _tmp5_;
			_tmp4_ = tetravex_cli_remaining;
			_tmp4__length1 = tetravex_cli_remaining_length1;
			_tmp5_ = _tmp4_[0];
			_tmp1_ = g_strcmp0 ((const gchar*) _tmp5_, "version") == 0;
		} else {
			_tmp1_ = FALSE;
		}
		_tmp0_ = _tmp1_;
	}
	if (_tmp0_) {
		FILE* _tmp6_;
		_tmp6_ = stderr;
		fprintf (_tmp6_, "%1$s %2$s\n", "gnome-tetravex-cli", VERSION);
		result = EXIT_SUCCESS;
		return result;
	}
	if (tetravex_cli_game_size != G_MININT) {
		gboolean _tmp8_ = FALSE;
		if (tetravex_cli_game_size < 2) {
			_tmp8_ = TRUE;
		} else {
			_tmp8_ = tetravex_cli_game_size > 6;
		}
		_tmp7_ = _tmp8_;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		FILE* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		_tmp9_ = stderr;
		_tmp10_ = g_strconcat (_ ("Size could only be from 2 to 6."), "\n", NULL);
		_tmp11_ = _tmp10_;
		fprintf (_tmp9_, "%s", _tmp11_);
		_g_free0 (_tmp11_);
		result = EXIT_FAILURE;
		return result;
	}
	if (tetravex_cli_colors < 2) {
		_tmp12_ = TRUE;
	} else {
		_tmp12_ = tetravex_cli_colors > 10;
	}
	if (_tmp12_) {
		FILE* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		_tmp13_ = stderr;
		_tmp14_ = g_strconcat (_ ("There could only be between 2 and 10 colors."), "\n", NULL);
		_tmp15_ = _tmp14_;
		fprintf (_tmp13_, "%s", _tmp15_);
		_g_free0 (_tmp15_);
		result = EXIT_FAILURE;
		return result;
	}
	_tmp16_ = tetravex_cli_remaining;
	_tmp16__length1 = tetravex_cli_remaining_length1;
	_tmp17_ = _tmp16_[1];
	if (_tmp17_ != NULL) {
		FILE* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		_tmp18_ = stderr;
		_tmp19_ = g_strconcat (_ ("Failed to parse command-line arguments."), "\n", NULL);
		_tmp20_ = _tmp19_;
		fprintf (_tmp18_, "%s", _tmp20_);
		_g_free0 (_tmp20_);
		result = EXIT_FAILURE;
		return result;
	}
	_tmp22_ = tetravex_cli_remaining;
	_tmp22__length1 = tetravex_cli_remaining_length1;
	_tmp23_ = _tmp22_[0];
	_tmp21_ = _tmp23_;
	if (_tmp21_ == NULL) {
		_tmp21_ = "";
	}
	_tmp24_ = g_strdup ((const gchar*) _tmp21_);
	_g_free0 (tetravex_cli_cli);
	tetravex_cli_cli = _tmp24_;
	_tmp26_ = tetravex_cli_cli;
	if (g_strcmp0 ((const gchar*) _tmp26_, "help") == 0) {
		_tmp25_ = TRUE;
	} else {
		const gchar* _tmp27_;
		_tmp27_ = tetravex_cli_cli;
		_tmp25_ = g_strcmp0 ((const gchar*) _tmp27_, "HELP") == 0;
	}
	if (_tmp25_) {
		FILE* _tmp28_;
		FILE* _tmp29_;
		FILE* _tmp30_;
		const gchar* _tmp31_;
		FILE* _tmp32_;
		_tmp28_ = stdout;
		fprintf (_tmp28_, "\n");
		_tmp29_ = stdout;
		fprintf (_tmp29_, "%s", _ ("To use `gnome-tetravex-cli`, pass as argument:"));
		_tmp30_ = stdout;
		_tmp31_ = self->priv->help_text;
		fprintf (_tmp30_, "%s", _tmp31_);
		_tmp32_ = stdout;
		fprintf (_tmp32_, "\n");
		result = EXIT_SUCCESS;
		return result;
	}
	_tmp33_ = tetravex_cli_cli;
	_tmp38_ = cli_play_cli ((const gchar*) _tmp33_, "org.gnome.TetravexCli", &_tmp34_, &_tmp35_, &_tmp36_, &_tmp37_, &tetravex_cli_colors, &tetravex_cli_game_size);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp34_;
	_g_variant_unref0 (self->priv->saved_game);
	self->priv->saved_game = _tmp35_;
	self->priv->can_restore = _tmp36_;
	_g_object_unref0 (self->priv->puzzle);
	self->priv->puzzle = _tmp37_;
	result = _tmp38_;
	return result;
}

static void
tetravex_cli_class_init (TetravexCliClass * klass,
                         gpointer klass_data)
{
	gchar** _tmp0_;
	tetravex_cli_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TetravexCli_private_offset);
	((GApplicationClass *) klass)->handle_local_options = (gint (*) (GApplication*, GVariantDict*)) tetravex_cli_real_handle_local_options;
	G_OBJECT_CLASS (klass)->finalize = tetravex_cli_finalize;
	_tmp0_ = g_new0 (gchar*, 2 + 1);
	tetravex_cli_remaining = _tmp0_;
	tetravex_cli_remaining_length1 = 2;
	_tetravex_cli_remaining_size_ = tetravex_cli_remaining_length1;
}

static void
tetravex_cli_instance_init (TetravexCli * self,
                            gpointer klass)
{
	gchar* _tmp0_;
	self->priv = tetravex_cli_get_instance_private (self);
	_tmp0_ = g_strdup (_ ("(nothing)"));
	self->priv->nothing_text = _tmp0_;
	self->priv->can_restore = FALSE;
}

static void
tetravex_cli_finalize (GObject * obj)
{
	TetravexCli * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TETRAVEX_CLI, TetravexCli);
	_g_free0 (self->priv->nothing_text);
	_g_free0 (self->priv->help_text);
	_g_variant_unref0 (self->priv->saved_game);
	_g_object_unref0 (self->priv->settings);
	_g_object_unref0 (self->priv->puzzle);
	G_OBJECT_CLASS (tetravex_cli_parent_class)->finalize (obj);
}

static GType
tetravex_cli_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TetravexCliClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tetravex_cli_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TetravexCli), 0, (GInstanceInitFunc) tetravex_cli_instance_init, NULL };
	GType tetravex_cli_type_id;
	tetravex_cli_type_id = g_type_register_static (g_application_get_type (), "TetravexCli", &g_define_type_info, 0);
	TetravexCli_private_offset = g_type_add_instance_private (tetravex_cli_type_id, sizeof (TetravexCliPrivate));
	return tetravex_cli_type_id;
}

GType
tetravex_cli_get_type (void)
{
	static volatile gsize tetravex_cli_type_id__once = 0;
	if (g_once_init_enter (&tetravex_cli_type_id__once)) {
		GType tetravex_cli_type_id;
		tetravex_cli_type_id = tetravex_cli_get_type_once ();
		g_once_init_leave (&tetravex_cli_type_id__once, tetravex_cli_type_id);
	}
	return tetravex_cli_type_id__once;
}

