/* steam-compatibility-tool-discovery.c generated by valac 0.56.19, the Vala compiler
 * generated from steam-compatibility-tool-discovery.vala, do not modify */

#include "protonplus_core.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <sys/stat.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

enum  {
	PROTON_PLUS_MODELS_STEAM_COMPATIBILITY_TOOL_DISCOVERY_0_PROPERTY,
	PROTON_PLUS_MODELS_STEAM_COMPATIBILITY_TOOL_DISCOVERY_NUM_PROPERTIES
};
static GParamSpec* proton_plus_models_steam_compatibility_tool_discovery_properties[PROTON_PLUS_MODELS_STEAM_COMPATIBILITY_TOOL_DISCOVERY_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef void (*ProtonPlusModelsSteamCompatibilityToolDiscoveryDirectoryChildCallback) (const gchar* name, const gchar* path, gpointer user_data);
typedef struct _Block39Data Block39Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _Block40Data Block40Data;

struct _ProtonPlusModelsSteamCompatibilityToolDiscoveryPrivate {
	ProtonPlusModelsLauncherInstallationTypes installation_type;
	gchar* system_root;
	gchar* system_inspection_root;
	gchar** flatpak_runtime_roots;
	gint flatpak_runtime_roots_length1;
	gint _flatpak_runtime_roots_size_;
	GeeHashMap* tools_by_internal_title;
	GeeHashMap* precedence_by_internal_title;
	GeeHashMap* internal_title_by_logical_location;
	GeeHashMap* steam_appid_by_internal_title;
};

struct _Block39Data {
	int _ref_count_;
	ProtonPlusModelsSteamCompatibilityToolDiscovery* self;
	gchar* active_deployment;
};

struct _Block40Data {
	int _ref_count_;
	ProtonPlusModelsSteamCompatibilityToolDiscovery* self;
	gchar* path_root;
	gboolean externally_managed;
	gint precedence;
};

static gint ProtonPlusModelsSteamCompatibilityToolDiscovery_private_offset;
static gpointer proton_plus_models_steam_compatibility_tool_discovery_parent_class = NULL;

static gchar** _vala_array_dup50 (gchar** self,
                           gssize length);
static gboolean proton_plus_models_steam_compatibility_tool_discovery_steam_library_tool_is_usable (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                                             ProtonPlusModelsCompatibilityTool* tool,
                                                                                             guint appid);
static void proton_plus_models_steam_compatibility_tool_discovery_add_tool (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                     ProtonPlusModelsCompatibilityTool* tool,
                                                                     gint precedence,
                                                                     guint steam_appid);
static void proton_plus_models_steam_compatibility_tool_discovery_discover_children (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                              const gchar* path_root,
                                                                              const gchar* inspection_root,
                                                                              gboolean externally_managed,
                                                                              gint precedence);
static void proton_plus_models_steam_compatibility_tool_discovery_discover_flatpak_extensions (ProtonPlusModelsSteamCompatibilityToolDiscovery* self);
static void proton_plus_models_steam_compatibility_tool_discovery_foreach_directory_child (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                                    const gchar* root,
                                                                                    ProtonPlusModelsSteamCompatibilityToolDiscoveryDirectoryChildCallback callback,
                                                                                    gpointer callback_target);
static void ____lambda15_ (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                    const gchar* extension_id,
                    const gchar* extension_root);
static void __lambda16_ (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                  const gchar* arch,
                  const gchar* arch_root);
static void __lambda17_ (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                  const gchar* branch,
                  const gchar* branch_root);
static Block39Data* block39_data_ref (Block39Data* _data39_);
static void block39_data_unref (void * _userdata_);
static gchar* proton_plus_models_steam_compatibility_tool_discovery_get_active_deployment_name (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                                         const gchar* branch_root);
static void __lambda18_ (Block39Data* _data39_,
                  const gchar* deployment,
                  const gchar* deployment_root);
static gboolean proton_plus_models_steam_compatibility_tool_discovery_is_directory_without_following (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                                               const gchar* path);
static void proton_plus_models_steam_compatibility_tool_discovery_add_tool_path (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                          const gchar* path,
                                                                          const gchar* inspection_path,
                                                                          gboolean externally_managed,
                                                                          gint precedence,
                                                                          ProtonPlusModelsCompatibilityToolRuntimeKind runtime_kind);
static void ___lambda18__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback (const gchar* name,
                                                                                                  const gchar* path,
                                                                                                  gpointer self);
static void ___lambda17__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback (const gchar* name,
                                                                                                  const gchar* path,
                                                                                                  gpointer self);
static void ___lambda16__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback (const gchar* name,
                                                                                                  const gchar* path,
                                                                                                  gpointer self);
static void _____lambda15__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback (const gchar* name,
                                                                                                    const gchar* path,
                                                                                                    gpointer self);
static gint ___lambda13_ (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                   const gchar* a,
                   const gchar* b);
static gint ____lambda13__gcompare_data_func (gconstpointer a,
                                       gconstpointer b,
                                       gpointer self);
static Block40Data* block40_data_ref (Block40Data* _data40_);
static void block40_data_unref (void * _userdata_);
static void __lambda14_ (Block40Data* _data40_,
                  const gchar* name,
                  const gchar* inspection_path);
static void ___lambda14__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback (const gchar* name,
                                                                                                  const gchar* path,
                                                                                                  gpointer self);
static gchar* proton_plus_models_steam_compatibility_tool_discovery_normalize_logical_location (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                                         const gchar* path);
static void proton_plus_models_steam_compatibility_tool_discovery_remove_tool (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                        const gchar* internal_title);
static void proton_plus_models_steam_compatibility_tool_discovery_finalize (GObject * obj);
static GType proton_plus_models_steam_compatibility_tool_discovery_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 inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
proton_plus_models_steam_compatibility_tool_discovery_get_instance_private (ProtonPlusModelsSteamCompatibilityToolDiscovery* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusModelsSteamCompatibilityToolDiscovery_private_offset);
}

static gchar**
_vala_array_dup50 (gchar** self,
                   gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

ProtonPlusModelsSteamCompatibilityToolDiscovery*
proton_plus_models_steam_compatibility_tool_discovery_construct (GType object_type,
                                                                 ProtonPlusModelsLauncherInstallationTypes installation_type,
                                                                 gboolean running_in_flatpak,
                                                                 const gchar* system_root,
                                                                 const gchar* system_inspection_root,
                                                                 gchar** flatpak_runtime_roots,
                                                                 gint flatpak_runtime_roots_length1)
{
	ProtonPlusModelsSteamCompatibilityToolDiscovery * self = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp3_;
	GeeHashMap* _tmp9_;
	GeeHashMap* _tmp10_;
	GeeHashMap* _tmp11_;
	GeeHashMap* _tmp12_;
	g_return_val_if_fail (system_root != NULL, NULL);
	g_return_val_if_fail (system_inspection_root != NULL, NULL);
	self = (ProtonPlusModelsSteamCompatibilityToolDiscovery*) g_object_new (object_type, NULL);
	self->priv->installation_type = installation_type;
	_tmp0_ = g_strdup (system_root);
	_g_free0 (self->priv->system_root);
	self->priv->system_root = _tmp0_;
	if (g_strcmp0 (system_inspection_root, "") != 0) {
		_tmp1_ = system_inspection_root;
	} else {
		const gchar* _tmp2_ = NULL;
		if (running_in_flatpak) {
			_tmp2_ = "/run/host/usr/share/steam/compatibilitytools.d";
		} else {
			_tmp2_ = system_root;
		}
		_tmp1_ = _tmp2_;
	}
	_tmp3_ = g_strdup (_tmp1_);
	_g_free0 (self->priv->system_inspection_root);
	self->priv->system_inspection_root = _tmp3_;
	if (flatpak_runtime_roots != NULL) {
		gchar** _tmp4_;
		gint _tmp4__length1;
		_tmp4_ = _vala_array_dup50 ((gchar**) flatpak_runtime_roots, (flatpak_runtime_roots_length1 * sizeof (gchar*)) / sizeof (gchar*));
		_tmp4__length1 = (flatpak_runtime_roots_length1 * sizeof (gchar*)) / sizeof (gchar*);
		self->priv->flatpak_runtime_roots = (_vala_array_free (self->priv->flatpak_runtime_roots, self->priv->flatpak_runtime_roots_length1, (GDestroyNotify) g_free), NULL);
		self->priv->flatpak_runtime_roots = _tmp4_;
		self->priv->flatpak_runtime_roots_length1 = _tmp4__length1;
		self->priv->_flatpak_runtime_roots_size_ = self->priv->flatpak_runtime_roots_length1;
	} else {
		const gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		gchar** _tmp8_;
		_tmp5_ = g_get_home_dir ();
		_tmp6_ = g_build_filename (_tmp5_, ".local", "share", "flatpak", "runtime", NULL);
		_tmp7_ = g_strdup ("/var/lib/flatpak/runtime");
		_tmp8_ = g_new0 (gchar*, 2 + 1);
		_tmp8_[0] = _tmp6_;
		_tmp8_[1] = _tmp7_;
		self->priv->flatpak_runtime_roots = (_vala_array_free (self->priv->flatpak_runtime_roots, self->priv->flatpak_runtime_roots_length1, (GDestroyNotify) g_free), NULL);
		self->priv->flatpak_runtime_roots = _tmp8_;
		self->priv->flatpak_runtime_roots_length1 = 2;
		self->priv->_flatpak_runtime_roots_size_ = self->priv->flatpak_runtime_roots_length1;
	}
	_tmp9_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, PROTON_PLUS_MODELS_TYPE_COMPATIBILITY_TOOL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->tools_by_internal_title);
	self->priv->tools_by_internal_title = _tmp9_;
	_tmp10_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_INT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->precedence_by_internal_title);
	self->priv->precedence_by_internal_title = _tmp10_;
	_tmp11_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->internal_title_by_logical_location);
	self->priv->internal_title_by_logical_location = _tmp11_;
	_tmp12_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_UINT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->steam_appid_by_internal_title);
	self->priv->steam_appid_by_internal_title = _tmp12_;
	return self;
}

ProtonPlusModelsSteamCompatibilityToolDiscovery*
proton_plus_models_steam_compatibility_tool_discovery_new (ProtonPlusModelsLauncherInstallationTypes installation_type,
                                                           gboolean running_in_flatpak,
                                                           const gchar* system_root,
                                                           const gchar* system_inspection_root,
                                                           gchar** flatpak_runtime_roots,
                                                           gint flatpak_runtime_roots_length1)
{
	return proton_plus_models_steam_compatibility_tool_discovery_construct (PROTON_PLUS_MODELS_TYPE_STEAM_COMPATIBILITY_TOOL_DISCOVERY, installation_type, running_in_flatpak, system_root, system_inspection_root, flatpak_runtime_roots, flatpak_runtime_roots_length1);
}

void
proton_plus_models_steam_compatibility_tool_discovery_clear (ProtonPlusModelsSteamCompatibilityToolDiscovery* self)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeHashMap* _tmp2_;
	GeeHashMap* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->tools_by_internal_title;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp0_);
	_tmp1_ = self->priv->precedence_by_internal_title;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp1_);
	_tmp2_ = self->priv->internal_title_by_logical_location;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp2_);
	_tmp3_ = self->priv->steam_appid_by_internal_title;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp3_);
}

void
proton_plus_models_steam_compatibility_tool_discovery_add_steam_library_app (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                             const gchar* path,
                                                                             guint appid,
                                                                             const gchar* internal_title,
                                                                             const gchar* display_title,
                                                                             ProtonPlusModelsCompatibilityToolRuntimeKind runtime_kind)
{
	ProtonPlusModelsCompatibilityTool* tool = NULL;
	ProtonPlusModelsCompatibilityTool* _tmp0_;
	ProtonPlusModelsCompatibilityTool* _tmp1_;
	ProtonPlusModelsCompatibilityTool* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path != NULL);
	g_return_if_fail (internal_title != NULL);
	g_return_if_fail (display_title != NULL);
	_tmp0_ = proton_plus_models_compatibility_tool_new (display_title, internal_title, path, runtime_kind, path, TRUE);
	tool = _tmp0_;
	_tmp1_ = tool;
	if (!proton_plus_models_steam_compatibility_tool_discovery_steam_library_tool_is_usable (self, _tmp1_, appid)) {
		_g_object_unref0 (tool);
		return;
	}
	_tmp2_ = tool;
	proton_plus_models_steam_compatibility_tool_discovery_add_tool (self, _tmp2_, 300, appid);
	_g_object_unref0 (tool);
}

gboolean
proton_plus_models_steam_compatibility_tool_discovery_try_get_steam_library_tool_identity (guint appid,
                                                                                           gchar** internal_title,
                                                                                           ProtonPlusModelsCompatibilityToolRuntimeKind* runtime_kind)
{
	gchar* _vala_internal_title = NULL;
	ProtonPlusModelsCompatibilityToolRuntimeKind _vala_runtime_kind = 0;
	gboolean result;
	_vala_runtime_kind = PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_PROTON;
	switch (appid) {
		case 2180100:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup ("proton_hotfix");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp0_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 1493710:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("proton_experimental");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp1_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 3658110:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup ("proton_10");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp2_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 4628710:
		{
			gchar* _tmp3_;
			_tmp3_ = g_strdup ("proton_11");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp3_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 2348590:
		{
			gchar* _tmp4_;
			_tmp4_ = g_strdup ("proton_8");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp4_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 2805730:
		{
			gchar* _tmp5_;
			_tmp5_ = g_strdup ("proton_9");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp5_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 1887720:
		{
			gchar* _tmp6_;
			_tmp6_ = g_strdup ("proton_7");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp6_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 1580130:
		{
			gchar* _tmp7_;
			_tmp7_ = g_strdup ("proton_63");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp7_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 1420170:
		{
			gchar* _tmp8_;
			_tmp8_ = g_strdup ("proton_513");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp8_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 1245040:
		{
			gchar* _tmp9_;
			_tmp9_ = g_strdup ("proton_5");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp9_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 1054830:
		{
			gchar* _tmp10_;
			_tmp10_ = g_strdup ("proton_411");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp10_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 1113280:
		{
			gchar* _tmp11_;
			_tmp11_ = g_strdup ("proton_42");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp11_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 961940:
		{
			gchar* _tmp12_;
			_tmp12_ = g_strdup ("proton_316");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp12_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 858280:
		{
			gchar* _tmp13_;
			_tmp13_ = g_strdup ("proton_37");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp13_;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 1070560:
		{
			gchar* _tmp14_;
			_tmp14_ = g_strdup ("steamlinuxruntime");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp14_;
			_vala_runtime_kind = PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_NATIVE;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 1391110:
		{
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("steamlinuxruntime_soldier");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp15_;
			_vala_runtime_kind = PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_NATIVE;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 1628350:
		{
			gchar* _tmp16_;
			_tmp16_ = g_strdup ("steamlinuxruntime_sniper");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp16_;
			_vala_runtime_kind = PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_NATIVE;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		case 4183110:
		{
			gchar* _tmp17_;
			_tmp17_ = g_strdup ("steamlinuxruntime_4");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp17_;
			_vala_runtime_kind = PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_NATIVE;
			result = TRUE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
		default:
		{
			gchar* _tmp18_;
			_tmp18_ = g_strdup ("");
			_g_free0 (_vala_internal_title);
			_vala_internal_title = _tmp18_;
			_vala_runtime_kind = PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_UNKNOWN;
			result = FALSE;
			if (internal_title) {
				*internal_title = _vala_internal_title;
			} else {
				_g_free0 (_vala_internal_title);
			}
			if (runtime_kind) {
				*runtime_kind = _vala_runtime_kind;
			}
			return result;
		}
	}
}

void
proton_plus_models_steam_compatibility_tool_discovery_discover_launcher_roots (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                               const gchar* managed_tools_root)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (managed_tools_root != NULL);
	proton_plus_models_steam_compatibility_tool_discovery_discover_children (self, managed_tools_root, managed_tools_root, FALSE, 100);
	if (self->priv->installation_type == PROTON_PLUS_MODELS_LAUNCHER_INSTALLATION_TYPES_SYSTEM) {
		const gchar* _tmp0_;
		const gchar* _tmp1_;
		_tmp0_ = self->priv->system_root;
		_tmp1_ = self->priv->system_inspection_root;
		proton_plus_models_steam_compatibility_tool_discovery_discover_children (self, _tmp0_, _tmp1_, TRUE, 200);
	} else {
		if (self->priv->installation_type == PROTON_PLUS_MODELS_LAUNCHER_INSTALLATION_TYPES_FLATPAK) {
			proton_plus_models_steam_compatibility_tool_discovery_discover_flatpak_extensions (self);
		}
	}
}

GeeList*
proton_plus_models_steam_compatibility_tool_discovery_get_snapshot (ProtonPlusModelsSteamCompatibilityToolDiscovery* self)
{
	GeeArrayList* snapshot = NULL;
	GeeArrayList* _tmp0_;
	GeeList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_COMPATIBILITY_TOOL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	snapshot = _tmp0_;
	{
		GeeIterator* _tool_it = NULL;
		GeeHashMap* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeCollection* _tmp4_;
		GeeIterator* _tmp5_;
		GeeIterator* _tmp6_;
		_tmp1_ = self->priv->tools_by_internal_title;
		_tmp2_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = _tmp3_;
		_tmp5_ = gee_iterable_iterator ((GeeIterable*) _tmp4_);
		_tmp6_ = _tmp5_;
		_g_object_unref0 (_tmp4_);
		_tool_it = _tmp6_;
		while (TRUE) {
			GeeIterator* _tmp7_;
			ProtonPlusModelsCompatibilityTool* tool = NULL;
			GeeIterator* _tmp8_;
			gpointer _tmp9_;
			GeeArrayList* _tmp10_;
			ProtonPlusModelsCompatibilityTool* _tmp11_;
			_tmp7_ = _tool_it;
			if (!gee_iterator_next (_tmp7_)) {
				break;
			}
			_tmp8_ = _tool_it;
			_tmp9_ = gee_iterator_get (_tmp8_);
			tool = (ProtonPlusModelsCompatibilityTool*) _tmp9_;
			_tmp10_ = snapshot;
			_tmp11_ = tool;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, _tmp11_);
			_g_object_unref0 (tool);
		}
		_g_object_unref0 (_tool_it);
	}
	result = (GeeList*) snapshot;
	return result;
}

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

gboolean
proton_plus_models_steam_compatibility_tool_discovery_remains_available (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                         ProtonPlusModelsCompatibilityTool* tool)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	gboolean _tmp2_;
	guint steam_appid = 0U;
	GeeHashMap* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gpointer _tmp10_;
	ProtonPlusModelsCompatibilityTool* current = NULL;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gboolean _tmp15_;
	gboolean _tmp16_;
	ProtonPlusModelsCompatibilityTool* _tmp17_;
	gboolean _tmp18_ = FALSE;
	ProtonPlusModelsCompatibilityTool* _tmp19_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (tool != NULL, FALSE);
	_tmp1_ = proton_plus_models_compatibility_tool_get_is_available (tool);
	_tmp2_ = _tmp1_;
	if (!_tmp2_) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp3_ = proton_plus_models_compatibility_tool_get_inspection_path (tool);
		_tmp4_ = _tmp3_;
		_tmp5_ = string_strip (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = g_strcmp0 (_tmp6_, "") == 0;
		_g_free0 (_tmp6_);
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp7_ = self->priv->steam_appid_by_internal_title;
	_tmp8_ = proton_plus_models_compatibility_tool_get_internal_title (tool);
	_tmp9_ = _tmp8_;
	_tmp10_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp7_, _tmp9_);
	steam_appid = (guint) ((guintptr) _tmp10_);
	if (steam_appid != ((guint) 0)) {
		result = proton_plus_models_steam_compatibility_tool_discovery_steam_library_tool_is_usable (self, tool, steam_appid);
		return result;
	}
	_tmp11_ = proton_plus_models_compatibility_tool_get_path (tool);
	_tmp12_ = _tmp11_;
	_tmp13_ = proton_plus_models_compatibility_tool_get_inspection_path (tool);
	_tmp14_ = _tmp13_;
	_tmp15_ = proton_plus_models_compatibility_tool_get_externally_managed (tool);
	_tmp16_ = _tmp15_;
	_tmp17_ = proton_plus_utils_vdf_compatibility_tool_loader_try_from_paths (_tmp12_, _tmp14_, _tmp16_);
	current = _tmp17_;
	_tmp19_ = current;
	if (_tmp19_ != NULL) {
		ProtonPlusModelsCompatibilityTool* _tmp20_;
		const gchar* _tmp21_;
		const gchar* _tmp22_;
		const gchar* _tmp23_;
		const gchar* _tmp24_;
		_tmp20_ = current;
		_tmp21_ = proton_plus_models_compatibility_tool_get_internal_title (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, PROTON_PLUS_MODELS_TYPE_COMPATIBILITY_TOOL, ProtonPlusModelsCompatibilityTool));
		_tmp22_ = _tmp21_;
		_tmp23_ = proton_plus_models_compatibility_tool_get_internal_title (tool);
		_tmp24_ = _tmp23_;
		_tmp18_ = g_strcmp0 (_tmp22_, _tmp24_) == 0;
	} else {
		_tmp18_ = FALSE;
	}
	result = _tmp18_;
	_g_object_unref0 (current);
	return result;
}

static Block39Data*
block39_data_ref (Block39Data* _data39_)
{
	g_atomic_int_inc (&_data39_->_ref_count_);
	return _data39_;
}

static void
block39_data_unref (void * _userdata_)
{
	Block39Data* _data39_;
	_data39_ = (Block39Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data39_->_ref_count_)) {
		ProtonPlusModelsSteamCompatibilityToolDiscovery* self;
		self = _data39_->self;
		_g_free0 (_data39_->active_deployment);
		_g_object_unref0 (self);
		g_slice_free (Block39Data, _data39_);
	}
}

static void
__lambda18_ (Block39Data* _data39_,
             const gchar* deployment,
             const gchar* deployment_root)
{
	ProtonPlusModelsSteamCompatibilityToolDiscovery* self;
	gint _tmp0_ = 0;
	gint precedence = 0;
	gchar* files_root = NULL;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* tools_root = NULL;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	self = _data39_->self;
	g_return_if_fail (deployment != NULL);
	g_return_if_fail (deployment_root != NULL);
	if (g_strcmp0 (deployment, "active") == 0) {
		return;
	}
	if (g_strcmp0 (deployment, _data39_->active_deployment) == 0) {
		_tmp0_ = 150;
	} else {
		_tmp0_ = 250;
	}
	precedence = _tmp0_;
	_tmp1_ = g_build_filename (deployment_root, "files", NULL);
	files_root = _tmp1_;
	_tmp2_ = files_root;
	if (!proton_plus_models_steam_compatibility_tool_discovery_is_directory_without_following (self, _tmp2_)) {
		_g_free0 (files_root);
		return;
	}
	_tmp3_ = files_root;
	_tmp4_ = files_root;
	proton_plus_models_steam_compatibility_tool_discovery_add_tool_path (self, _tmp3_, _tmp4_, TRUE, precedence, PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_UNKNOWN);
	_tmp5_ = files_root;
	_tmp6_ = g_build_filename (_tmp5_, "share", "steam", "compatibilitytools.d", NULL);
	tools_root = _tmp6_;
	_tmp7_ = tools_root;
	_tmp8_ = tools_root;
	proton_plus_models_steam_compatibility_tool_discovery_discover_children (self, _tmp7_, _tmp8_, TRUE, precedence);
	_g_free0 (tools_root);
	_g_free0 (files_root);
}

static void
___lambda18__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback (const gchar* name,
                                                                                             const gchar* path,
                                                                                             gpointer self)
{
	__lambda18_ (self, name, path);
}

static void
__lambda17_ (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
             const gchar* branch,
             const gchar* branch_root)
{
	Block39Data* _data39_;
	gchar* _tmp0_;
	g_return_if_fail (branch != NULL);
	g_return_if_fail (branch_root != NULL);
	_data39_ = g_slice_new0 (Block39Data);
	_data39_->_ref_count_ = 1;
	_data39_->self = g_object_ref (self);
	_tmp0_ = proton_plus_models_steam_compatibility_tool_discovery_get_active_deployment_name (self, branch_root);
	_data39_->active_deployment = _tmp0_;
	proton_plus_models_steam_compatibility_tool_discovery_foreach_directory_child (self, branch_root, ___lambda18__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback, _data39_);
	block39_data_unref (_data39_);
	_data39_ = NULL;
}

static void
___lambda17__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback (const gchar* name,
                                                                                             const gchar* path,
                                                                                             gpointer self)
{
	__lambda17_ ((ProtonPlusModelsSteamCompatibilityToolDiscovery*) self, name, path);
}

static void
__lambda16_ (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
             const gchar* arch,
             const gchar* arch_root)
{
	g_return_if_fail (arch != NULL);
	g_return_if_fail (arch_root != NULL);
	proton_plus_models_steam_compatibility_tool_discovery_foreach_directory_child (self, arch_root, ___lambda17__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback, self);
}

static void
___lambda16__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback (const gchar* name,
                                                                                             const gchar* path,
                                                                                             gpointer self)
{
	__lambda16_ ((ProtonPlusModelsSteamCompatibilityToolDiscovery*) self, name, path);
}

static void
____lambda15_ (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
               const gchar* extension_id,
               const gchar* extension_root)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (extension_id != NULL);
	g_return_if_fail (extension_root != NULL);
	if (g_str_has_prefix (extension_id, "com.valvesoftware.Steam.CompatibilityTool.")) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_str_has_prefix (extension_id, "com.valvesoftware.Steam.Utility.");
	}
	if (!_tmp0_) {
		return;
	}
	proton_plus_models_steam_compatibility_tool_discovery_foreach_directory_child (self, extension_root, ___lambda16__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback, self);
}

static void
_____lambda15__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback (const gchar* name,
                                                                                               const gchar* path,
                                                                                               gpointer self)
{
	____lambda15_ ((ProtonPlusModelsSteamCompatibilityToolDiscovery*) self, name, path);
}

static void
proton_plus_models_steam_compatibility_tool_discovery_discover_flatpak_extensions (ProtonPlusModelsSteamCompatibilityToolDiscovery* self)
{
	gchar** _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->flatpak_runtime_roots;
	_tmp0__length1 = self->priv->flatpak_runtime_roots_length1;
	{
		gchar** runtime_root_collection = NULL;
		gint runtime_root_collection_length1 = 0;
		gint _runtime_root_collection_size_ = 0;
		gint runtime_root_it = 0;
		runtime_root_collection = _tmp0_;
		runtime_root_collection_length1 = _tmp0__length1;
		for (runtime_root_it = 0; runtime_root_it < runtime_root_collection_length1; runtime_root_it = runtime_root_it + 1) {
			gchar* _tmp1_;
			gchar* runtime_root = NULL;
			_tmp1_ = g_strdup (runtime_root_collection[runtime_root_it]);
			runtime_root = _tmp1_;
			{
				const gchar* _tmp2_;
				_tmp2_ = runtime_root;
				proton_plus_models_steam_compatibility_tool_discovery_foreach_directory_child (self, _tmp2_, _____lambda15__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback, self);
				_g_free0 (runtime_root);
			}
		}
	}
}

static gint
___lambda13_ (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
              const gchar* a,
              const gchar* b)
{
	GCompareFunc _tmp0_;
	gint result;
	g_return_val_if_fail (a != NULL, -1);
	g_return_val_if_fail (b != NULL, -1);
	_tmp0_ = ((GCompareFunc) g_strcmp0);
	result = _tmp0_ (a, b);
	return result;
}

static gint
____lambda13__gcompare_data_func (gconstpointer a,
                                  gconstpointer b,
                                  gpointer self)
{
	gint result;
	result = ___lambda13_ ((ProtonPlusModelsSteamCompatibilityToolDiscovery*) self, (const gchar*) a, (const gchar*) b);
	return result;
}

static void
proton_plus_models_steam_compatibility_tool_discovery_foreach_directory_child (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                               const gchar* root,
                                                                               ProtonPlusModelsSteamCompatibilityToolDiscoveryDirectoryChildCallback callback,
                                                                               gpointer callback_target)
{
	GFileEnumerator* enumerator = NULL;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (root != NULL);
	if (!proton_plus_models_steam_compatibility_tool_discovery_is_directory_without_following (self, root)) {
		return;
	}
	enumerator = NULL;
	{
		GeeArrayList* names = NULL;
		GeeArrayList* _tmp0_;
		GFileEnumerator* _tmp1_ = NULL;
		GFile* _tmp2_;
		GFile* _tmp3_;
		GFileEnumerator* _tmp4_;
		GFileEnumerator* _tmp5_;
		GFileEnumerator* _tmp6_;
		GFileInfo* info = NULL;
		GeeArrayList* _tmp20_;
		_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
		names = _tmp0_;
		_tmp2_ = g_file_new_for_path (root);
		_tmp3_ = _tmp2_;
		_tmp4_ = g_file_enumerate_children (_tmp3_, "standard::name,standard::type", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &_inner_error0_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_tmp1_ = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (names);
			goto __catch0_g_error;
		}
		_tmp6_ = _tmp1_;
		_tmp1_ = NULL;
		_g_object_unref0 (enumerator);
		enumerator = _tmp6_;
		while (TRUE) {
			GFileInfo* _tmp7_ = NULL;
			GFileEnumerator* _tmp8_;
			GFileInfo* _tmp9_;
			GFileInfo* _tmp10_;
			GFileInfo* _tmp11_;
			GFileInfo* _tmp12_;
			gchar* child = NULL;
			GFileInfo* _tmp13_;
			const gchar* _tmp14_;
			gchar* _tmp15_;
			const gchar* _tmp16_;
			GeeArrayList* _tmp17_;
			GFileInfo* _tmp18_;
			const gchar* _tmp19_;
			_tmp8_ = enumerator;
			_tmp9_ = g_file_enumerator_next_file (_tmp8_, NULL, &_inner_error0_);
			_tmp7_ = _tmp9_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (info);
				_g_object_unref0 (_tmp1_);
				_g_object_unref0 (names);
				goto __catch0_g_error;
			}
			_tmp10_ = _tmp7_;
			_tmp7_ = NULL;
			_g_object_unref0 (info);
			info = _tmp10_;
			_tmp11_ = info;
			if (!(_tmp11_ != NULL)) {
				_g_object_unref0 (_tmp7_);
				break;
			}
			_tmp12_ = info;
			if (g_file_info_get_file_type (_tmp12_) != G_FILE_TYPE_DIRECTORY) {
				_g_object_unref0 (_tmp7_);
				continue;
			}
			_tmp13_ = info;
			_tmp14_ = g_file_info_get_name (_tmp13_);
			_tmp15_ = g_build_filename (root, _tmp14_, NULL);
			child = _tmp15_;
			_tmp16_ = child;
			if (!proton_plus_models_steam_compatibility_tool_discovery_is_directory_without_following (self, _tmp16_)) {
				_g_free0 (child);
				_g_object_unref0 (_tmp7_);
				continue;
			}
			_tmp17_ = names;
			_tmp18_ = info;
			_tmp19_ = g_file_info_get_name (_tmp18_);
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp17_, _tmp19_);
			_g_free0 (child);
			_g_object_unref0 (_tmp7_);
		}
		_tmp20_ = names;
		gee_list_sort ((GeeList*) _tmp20_, ____lambda13__gcompare_data_func, g_object_ref (self), g_object_unref);
		{
			GeeArrayList* _name_list = NULL;
			GeeArrayList* _tmp21_;
			gint _name_size = 0;
			GeeArrayList* _tmp22_;
			gint _tmp23_;
			gint _tmp24_;
			gint _name_index = 0;
			_tmp21_ = names;
			_name_list = _tmp21_;
			_tmp22_ = _name_list;
			_tmp23_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp22_);
			_tmp24_ = _tmp23_;
			_name_size = _tmp24_;
			_name_index = -1;
			while (TRUE) {
				gint _tmp25_;
				gint _tmp26_;
				gchar* name = NULL;
				GeeArrayList* _tmp27_;
				gpointer _tmp28_;
				const gchar* _tmp29_;
				const gchar* _tmp30_;
				gchar* _tmp31_;
				gchar* _tmp32_;
				_name_index = _name_index + 1;
				_tmp25_ = _name_index;
				_tmp26_ = _name_size;
				if (!(_tmp25_ < _tmp26_)) {
					break;
				}
				_tmp27_ = _name_list;
				_tmp28_ = gee_abstract_list_get ((GeeAbstractList*) _tmp27_, _name_index);
				name = (gchar*) _tmp28_;
				_tmp29_ = name;
				_tmp30_ = name;
				_tmp31_ = g_build_filename (root, _tmp30_, NULL);
				_tmp32_ = _tmp31_;
				callback (_tmp29_, _tmp32_, callback_target);
				_g_free0 (_tmp32_);
				_g_free0 (name);
			}
		}
		_g_object_unref0 (info);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (names);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp33_;
		const gchar* _tmp34_;
		_error_ = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp33_ = _error_;
		_tmp34_ = _tmp33_->message;
		g_debug ("steam-compatibility-tool-discovery.vala:190: Compatibility-tool root %" \
"s is unavailable: %s", root, _tmp34_);
		_g_error_free0 (_error_);
	}
	__finally0:
	{
		GError* _inner_error1_ = NULL;
		GFileEnumerator* _tmp35_;
		_tmp35_ = enumerator;
		if (_tmp35_ != NULL) {
			{
				GFileEnumerator* _tmp36_;
				_tmp36_ = enumerator;
				g_file_enumerator_close (G_TYPE_CHECK_INSTANCE_CAST (_tmp36_, g_file_enumerator_get_type (), GFileEnumerator), NULL, &_inner_error1_);
				if (G_UNLIKELY (_inner_error1_ != NULL)) {
					goto __catch1_g_error;
				}
			}
			goto __finally1;
			__catch1_g_error:
			{
				g_clear_error (&_inner_error1_);
			}
			__finally1:
			if (G_UNLIKELY (_inner_error1_ != NULL)) {
				_g_object_unref0 (enumerator);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error1_->message, g_quark_to_string (_inner_error1_->domain), _inner_error1_->code);
				g_clear_error (&_inner_error1_);
				return;
			}
		}
	}
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (enumerator);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_g_object_unref0 (enumerator);
}

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

static gchar*
proton_plus_models_steam_compatibility_tool_discovery_get_active_deployment_name (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                                  const gchar* branch_root)
{
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (branch_root != NULL, NULL);
	{
		GFileInfo* info = NULL;
		gchar* _tmp0_;
		gchar* _tmp1_;
		GFile* _tmp2_;
		GFile* _tmp3_;
		GFileInfo* _tmp4_;
		GFileInfo* _tmp5_;
		GFileInfo* _tmp6_;
		gchar* target = NULL;
		GFileInfo* _tmp8_;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		gboolean _tmp11_ = FALSE;
		gboolean _tmp12_ = FALSE;
		gboolean _tmp13_ = FALSE;
		gboolean _tmp14_ = FALSE;
		gboolean _tmp15_ = FALSE;
		const gchar* _tmp16_;
		const gchar* _tmp23_;
		gchar* _tmp24_;
		_tmp0_ = g_build_filename (branch_root, "active", NULL);
		_tmp1_ = _tmp0_;
		_tmp2_ = g_file_new_for_path (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = g_file_query_info (_tmp3_, "standard::type,standard::symlink-target", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &_inner_error0_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_g_free0 (_tmp1_);
		info = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp6_ = info;
		if (g_file_info_get_file_type (_tmp6_) != G_FILE_TYPE_SYMBOLIC_LINK) {
			gchar* _tmp7_;
			_tmp7_ = g_strdup ("");
			result = _tmp7_;
			_g_object_unref0 (info);
			return result;
		}
		_tmp8_ = info;
		_tmp9_ = g_file_info_get_symlink_target (_tmp8_);
		_tmp10_ = g_strdup (_tmp9_);
		target = _tmp10_;
		_tmp16_ = target;
		if (_tmp16_ == NULL) {
			_tmp15_ = TRUE;
		} else {
			const gchar* _tmp17_;
			_tmp17_ = target;
			_tmp15_ = g_strcmp0 (_tmp17_, "") == 0;
		}
		if (_tmp15_) {
			_tmp14_ = TRUE;
		} else {
			const gchar* _tmp18_;
			_tmp18_ = target;
			_tmp14_ = g_path_is_absolute ((const gchar*) _tmp18_);
		}
		if (_tmp14_) {
			_tmp13_ = TRUE;
		} else {
			const gchar* _tmp19_;
			_tmp19_ = target;
			_tmp13_ = string_contains ((const gchar*) _tmp19_, "/");
		}
		if (_tmp13_) {
			_tmp12_ = TRUE;
		} else {
			const gchar* _tmp20_;
			_tmp20_ = target;
			_tmp12_ = g_strcmp0 ((const gchar*) _tmp20_, ".") == 0;
		}
		if (_tmp12_) {
			_tmp11_ = TRUE;
		} else {
			const gchar* _tmp21_;
			_tmp21_ = target;
			_tmp11_ = g_strcmp0 ((const gchar*) _tmp21_, "..") == 0;
		}
		if (_tmp11_) {
			gchar* _tmp22_;
			_tmp22_ = g_strdup ("");
			result = _tmp22_;
			_g_free0 (target);
			_g_object_unref0 (info);
			return result;
		}
		_tmp23_ = target;
		_tmp24_ = g_strdup ((const gchar*) _tmp23_);
		result = _tmp24_;
		_g_free0 (target);
		_g_object_unref0 (info);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		gchar* _tmp25_;
		g_clear_error (&_inner_error0_);
		_tmp25_ = g_strdup ("");
		result = _tmp25_;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static Block40Data*
block40_data_ref (Block40Data* _data40_)
{
	g_atomic_int_inc (&_data40_->_ref_count_);
	return _data40_;
}

static void
block40_data_unref (void * _userdata_)
{
	Block40Data* _data40_;
	_data40_ = (Block40Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data40_->_ref_count_)) {
		ProtonPlusModelsSteamCompatibilityToolDiscovery* self;
		self = _data40_->self;
		_g_free0 (_data40_->path_root);
		_g_object_unref0 (self);
		g_slice_free (Block40Data, _data40_);
	}
}

static void
__lambda14_ (Block40Data* _data40_,
             const gchar* name,
             const gchar* inspection_path)
{
	ProtonPlusModelsSteamCompatibilityToolDiscovery* self;
	gchar* _tmp0_;
	gchar* _tmp1_;
	self = _data40_->self;
	g_return_if_fail (name != NULL);
	g_return_if_fail (inspection_path != NULL);
	_tmp0_ = g_build_filename (_data40_->path_root, name, NULL);
	_tmp1_ = _tmp0_;
	proton_plus_models_steam_compatibility_tool_discovery_add_tool_path (self, _tmp1_, inspection_path, _data40_->externally_managed, _data40_->precedence, PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_UNKNOWN);
	_g_free0 (_tmp1_);
}

static void
___lambda14__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback (const gchar* name,
                                                                                             const gchar* path,
                                                                                             gpointer self)
{
	__lambda14_ (self, name, path);
}

static void
proton_plus_models_steam_compatibility_tool_discovery_discover_children (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                         const gchar* path_root,
                                                                         const gchar* inspection_root,
                                                                         gboolean externally_managed,
                                                                         gint precedence)
{
	Block40Data* _data40_;
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path_root != NULL);
	g_return_if_fail (inspection_root != NULL);
	_data40_ = g_slice_new0 (Block40Data);
	_data40_->_ref_count_ = 1;
	_data40_->self = g_object_ref (self);
	_tmp0_ = g_strdup (path_root);
	_g_free0 (_data40_->path_root);
	_data40_->path_root = _tmp0_;
	_data40_->externally_managed = externally_managed;
	_data40_->precedence = precedence;
	proton_plus_models_steam_compatibility_tool_discovery_foreach_directory_child (self, inspection_root, ___lambda14__proton_plus_models_steam_compatibility_tool_discovery_directory_child_callback, _data40_);
	block40_data_unref (_data40_);
	_data40_ = NULL;
}

static void
proton_plus_models_steam_compatibility_tool_discovery_add_tool_path (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                     const gchar* path,
                                                                     const gchar* inspection_path,
                                                                     gboolean externally_managed,
                                                                     gint precedence,
                                                                     ProtonPlusModelsCompatibilityToolRuntimeKind runtime_kind)
{
	ProtonPlusModelsCompatibilityTool* tool = NULL;
	ProtonPlusModelsCompatibilityTool* _tmp0_;
	ProtonPlusModelsCompatibilityTool* _tmp1_;
	ProtonPlusModelsCompatibilityTool* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path != NULL);
	g_return_if_fail (inspection_path != NULL);
	_tmp0_ = proton_plus_utils_vdf_compatibility_tool_loader_try_from_paths (path, inspection_path, externally_managed);
	tool = _tmp0_;
	_tmp1_ = tool;
	if (_tmp1_ == NULL) {
		_g_object_unref0 (tool);
		return;
	}
	if (runtime_kind != PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_UNKNOWN) {
		ProtonPlusModelsCompatibilityTool* _tmp2_;
		_tmp2_ = tool;
		proton_plus_models_compatibility_tool_set_runtime_kind (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, PROTON_PLUS_MODELS_TYPE_COMPATIBILITY_TOOL, ProtonPlusModelsCompatibilityTool), runtime_kind);
	}
	_tmp3_ = tool;
	proton_plus_models_steam_compatibility_tool_discovery_add_tool (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, PROTON_PLUS_MODELS_TYPE_COMPATIBILITY_TOOL, ProtonPlusModelsCompatibilityTool), precedence, (guint) 0);
	_g_object_unref0 (tool);
}

static void
proton_plus_models_steam_compatibility_tool_discovery_add_tool (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                ProtonPlusModelsCompatibilityTool* tool,
                                                                gint precedence,
                                                                guint steam_appid)
{
	gchar* logical_location = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* location_internal_title = NULL;
	GeeHashMap* _tmp3_;
	const gchar* _tmp4_;
	gpointer _tmp5_;
	const gchar* _tmp6_;
	gint existing_precedence = 0;
	GeeHashMap* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	gpointer _tmp14_;
	gboolean _tmp15_ = FALSE;
	GeeHashMap* _tmp16_;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	GeeHashMap* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	GeeHashMap* _tmp24_;
	const gchar* _tmp25_;
	const gchar* _tmp26_;
	GeeHashMap* _tmp27_;
	const gchar* _tmp28_;
	const gchar* _tmp29_;
	GeeHashMap* _tmp30_;
	const gchar* _tmp31_;
	const gchar* _tmp32_;
	const gchar* _tmp33_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tool != NULL);
	_tmp0_ = proton_plus_models_compatibility_tool_get_path (tool);
	_tmp1_ = _tmp0_;
	_tmp2_ = proton_plus_models_steam_compatibility_tool_discovery_normalize_logical_location (self, _tmp1_);
	logical_location = _tmp2_;
	_tmp3_ = self->priv->internal_title_by_logical_location;
	_tmp4_ = logical_location;
	_tmp5_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp3_, _tmp4_);
	location_internal_title = (gchar*) _tmp5_;
	_tmp6_ = location_internal_title;
	if (_tmp6_ != NULL) {
		gint location_precedence = 0;
		GeeHashMap* _tmp7_;
		const gchar* _tmp8_;
		gpointer _tmp9_;
		const gchar* _tmp10_;
		_tmp7_ = self->priv->precedence_by_internal_title;
		_tmp8_ = location_internal_title;
		_tmp9_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp7_, (const gchar*) _tmp8_);
		location_precedence = (gint) ((gintptr) _tmp9_);
		if (location_precedence <= precedence) {
			_g_free0 (location_internal_title);
			_g_free0 (logical_location);
			return;
		}
		_tmp10_ = location_internal_title;
		proton_plus_models_steam_compatibility_tool_discovery_remove_tool (self, (const gchar*) _tmp10_);
	}
	_tmp11_ = self->priv->precedence_by_internal_title;
	_tmp12_ = proton_plus_models_compatibility_tool_get_internal_title (tool);
	_tmp13_ = _tmp12_;
	_tmp14_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp11_, _tmp13_);
	existing_precedence = (gint) ((gintptr) _tmp14_);
	_tmp16_ = self->priv->tools_by_internal_title;
	_tmp17_ = proton_plus_models_compatibility_tool_get_internal_title (tool);
	_tmp18_ = _tmp17_;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp16_, _tmp18_)) {
		_tmp15_ = existing_precedence <= precedence;
	} else {
		_tmp15_ = FALSE;
	}
	if (_tmp15_) {
		_g_free0 (location_internal_title);
		_g_free0 (logical_location);
		return;
	}
	_tmp19_ = self->priv->tools_by_internal_title;
	_tmp20_ = proton_plus_models_compatibility_tool_get_internal_title (tool);
	_tmp21_ = _tmp20_;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp19_, _tmp21_)) {
		const gchar* _tmp22_;
		const gchar* _tmp23_;
		_tmp22_ = proton_plus_models_compatibility_tool_get_internal_title (tool);
		_tmp23_ = _tmp22_;
		proton_plus_models_steam_compatibility_tool_discovery_remove_tool (self, _tmp23_);
	}
	_tmp24_ = self->priv->tools_by_internal_title;
	_tmp25_ = proton_plus_models_compatibility_tool_get_internal_title (tool);
	_tmp26_ = _tmp25_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp24_, _tmp26_, tool);
	_tmp27_ = self->priv->precedence_by_internal_title;
	_tmp28_ = proton_plus_models_compatibility_tool_get_internal_title (tool);
	_tmp29_ = _tmp28_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp27_, _tmp29_, (gpointer) ((gintptr) precedence));
	_tmp30_ = self->priv->internal_title_by_logical_location;
	_tmp31_ = logical_location;
	_tmp32_ = proton_plus_models_compatibility_tool_get_internal_title (tool);
	_tmp33_ = _tmp32_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp30_, _tmp31_, _tmp33_);
	if (steam_appid != ((guint) 0)) {
		GeeHashMap* _tmp34_;
		const gchar* _tmp35_;
		const gchar* _tmp36_;
		_tmp34_ = self->priv->steam_appid_by_internal_title;
		_tmp35_ = proton_plus_models_compatibility_tool_get_internal_title (tool);
		_tmp36_ = _tmp35_;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp34_, _tmp36_, (gpointer) ((guintptr) steam_appid));
	}
	_g_free0 (location_internal_title);
	_g_free0 (logical_location);
}

static void
proton_plus_models_steam_compatibility_tool_discovery_remove_tool (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                   const gchar* internal_title)
{
	ProtonPlusModelsCompatibilityTool* existing = NULL;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	ProtonPlusModelsCompatibilityTool* _tmp2_;
	GeeHashMap* _tmp9_;
	GeeHashMap* _tmp10_;
	GeeHashMap* _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (internal_title != NULL);
	_tmp0_ = self->priv->tools_by_internal_title;
	_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, internal_title);
	existing = (ProtonPlusModelsCompatibilityTool*) _tmp1_;
	_tmp2_ = existing;
	if (_tmp2_ != NULL) {
		GeeHashMap* _tmp3_;
		ProtonPlusModelsCompatibilityTool* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		_tmp3_ = self->priv->internal_title_by_logical_location;
		_tmp4_ = existing;
		_tmp5_ = proton_plus_models_compatibility_tool_get_path (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, PROTON_PLUS_MODELS_TYPE_COMPATIBILITY_TOOL, ProtonPlusModelsCompatibilityTool));
		_tmp6_ = _tmp5_;
		_tmp7_ = proton_plus_models_steam_compatibility_tool_discovery_normalize_logical_location (self, _tmp6_);
		_tmp8_ = _tmp7_;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp3_, _tmp8_, NULL);
		_g_free0 (_tmp8_);
	}
	_tmp9_ = self->priv->tools_by_internal_title;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp9_, internal_title, NULL);
	_tmp10_ = self->priv->precedence_by_internal_title;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp10_, internal_title, NULL);
	_tmp11_ = self->priv->steam_appid_by_internal_title;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp11_, internal_title, NULL);
	_g_object_unref0 (existing);
}

static gboolean
proton_plus_models_steam_compatibility_tool_discovery_steam_library_tool_is_usable (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                                    ProtonPlusModelsCompatibilityTool* tool,
                                                                                    guint appid)
{
	gchar* expected_internal_title = NULL;
	ProtonPlusModelsCompatibilityToolRuntimeKind expected_runtime_kind = 0;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gchar* _tmp3_ = NULL;
	ProtonPlusModelsCompatibilityToolRuntimeKind _tmp4_ = 0;
	gboolean _tmp5_;
	struct stat manifest_stat = {0};
	gboolean _tmp13_ = FALSE;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	struct stat _tmp18_ = {0};
	gint _tmp19_;
	gboolean _tmp20_;
	struct stat proton_stat = {0};
	gboolean _tmp22_ = FALSE;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	struct stat _tmp27_ = {0};
	gint _tmp28_;
	gboolean _tmp29_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (tool != NULL, FALSE);
	_tmp5_ = proton_plus_models_steam_compatibility_tool_discovery_try_get_steam_library_tool_identity (appid, &_tmp3_, &_tmp4_);
	_g_free0 (expected_internal_title);
	expected_internal_title = _tmp3_;
	expected_runtime_kind = _tmp4_;
	if (!_tmp5_) {
		_tmp2_ = TRUE;
	} else {
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp6_ = expected_internal_title;
		_tmp7_ = proton_plus_models_compatibility_tool_get_internal_title (tool);
		_tmp8_ = _tmp7_;
		_tmp2_ = g_strcmp0 (_tmp6_, _tmp8_) != 0;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		ProtonPlusModelsCompatibilityToolRuntimeKind _tmp9_;
		ProtonPlusModelsCompatibilityToolRuntimeKind _tmp10_;
		_tmp9_ = proton_plus_models_compatibility_tool_get_runtime_kind (tool);
		_tmp10_ = _tmp9_;
		_tmp1_ = expected_runtime_kind != _tmp10_;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		_tmp11_ = proton_plus_models_compatibility_tool_get_inspection_path (tool);
		_tmp12_ = _tmp11_;
		_tmp0_ = !proton_plus_models_steam_compatibility_tool_discovery_is_directory_without_following (self, _tmp12_);
	}
	if (_tmp0_) {
		result = FALSE;
		_g_free0 (expected_internal_title);
		return result;
	}
	_tmp14_ = proton_plus_models_compatibility_tool_get_inspection_path (tool);
	_tmp15_ = _tmp14_;
	_tmp16_ = g_build_filename (_tmp15_, "toolmanifest.vdf", NULL);
	_tmp17_ = _tmp16_;
	_tmp19_ = lstat (_tmp17_, &_tmp18_);
	manifest_stat = _tmp18_;
	_tmp20_ = _tmp19_ != 0;
	_g_free0 (_tmp17_);
	if (_tmp20_) {
		_tmp13_ = TRUE;
	} else {
		struct stat _tmp21_;
		_tmp21_ = manifest_stat;
		_tmp13_ = !S_ISREG (_tmp21_.st_mode);
	}
	if (_tmp13_) {
		result = FALSE;
		_g_free0 (expected_internal_title);
		return result;
	}
	if (expected_runtime_kind != PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_PROTON) {
		result = TRUE;
		_g_free0 (expected_internal_title);
		return result;
	}
	_tmp23_ = proton_plus_models_compatibility_tool_get_inspection_path (tool);
	_tmp24_ = _tmp23_;
	_tmp25_ = g_build_filename (_tmp24_, "proton", NULL);
	_tmp26_ = _tmp25_;
	_tmp28_ = lstat (_tmp26_, &_tmp27_);
	proton_stat = _tmp27_;
	_tmp29_ = _tmp28_ == 0;
	_g_free0 (_tmp26_);
	if (_tmp29_) {
		struct stat _tmp30_;
		_tmp30_ = proton_stat;
		_tmp22_ = S_ISREG (_tmp30_.st_mode);
	} else {
		_tmp22_ = FALSE;
	}
	result = _tmp22_;
	_g_free0 (expected_internal_title);
	return result;
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static gchar*
proton_plus_models_steam_compatibility_tool_discovery_normalize_logical_location (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                                  const gchar* path)
{
	gchar* canonical = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (path != NULL, NULL);
	_tmp0_ = g_canonicalize_filename (path, NULL);
	canonical = _tmp0_;
	_tmp1_ = canonical;
	if (g_str_has_prefix (_tmp1_, "/run/host/")) {
		const gchar* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gchar* _tmp5_;
		_tmp2_ = canonical;
		_tmp3_ = strlen ("/run/host");
		_tmp4_ = _tmp3_;
		_tmp5_ = string_substring (_tmp2_, (glong) _tmp4_, (glong) -1);
		result = _tmp5_;
		_g_free0 (canonical);
		return result;
	}
	result = canonical;
	return result;
}

static gboolean
proton_plus_models_steam_compatibility_tool_discovery_is_directory_without_following (ProtonPlusModelsSteamCompatibilityToolDiscovery* self,
                                                                                      const gchar* path)
{
	struct stat stat = {0};
	gboolean _tmp0_ = FALSE;
	struct stat _tmp1_ = {0};
	gint _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (path != NULL, FALSE);
	_tmp2_ = lstat (path, &_tmp1_);
	stat = _tmp1_;
	if (_tmp2_ == 0) {
		struct stat _tmp3_;
		_tmp3_ = stat;
		_tmp0_ = S_ISDIR (_tmp3_.st_mode);
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static void
proton_plus_models_steam_compatibility_tool_discovery_class_init (ProtonPlusModelsSteamCompatibilityToolDiscoveryClass * klass,
                                                                  gpointer klass_data)
{
	proton_plus_models_steam_compatibility_tool_discovery_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusModelsSteamCompatibilityToolDiscovery_private_offset);
	G_OBJECT_CLASS (klass)->finalize = proton_plus_models_steam_compatibility_tool_discovery_finalize;
}

static void
proton_plus_models_steam_compatibility_tool_discovery_instance_init (ProtonPlusModelsSteamCompatibilityToolDiscovery * self,
                                                                     gpointer klass)
{
	self->priv = proton_plus_models_steam_compatibility_tool_discovery_get_instance_private (self);
}

static void
proton_plus_models_steam_compatibility_tool_discovery_finalize (GObject * obj)
{
	ProtonPlusModelsSteamCompatibilityToolDiscovery * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_MODELS_TYPE_STEAM_COMPATIBILITY_TOOL_DISCOVERY, ProtonPlusModelsSteamCompatibilityToolDiscovery);
	_g_free0 (self->priv->system_root);
	_g_free0 (self->priv->system_inspection_root);
	self->priv->flatpak_runtime_roots = (_vala_array_free (self->priv->flatpak_runtime_roots, self->priv->flatpak_runtime_roots_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (self->priv->tools_by_internal_title);
	_g_object_unref0 (self->priv->precedence_by_internal_title);
	_g_object_unref0 (self->priv->internal_title_by_logical_location);
	_g_object_unref0 (self->priv->steam_appid_by_internal_title);
	G_OBJECT_CLASS (proton_plus_models_steam_compatibility_tool_discovery_parent_class)->finalize (obj);
}

static GType
proton_plus_models_steam_compatibility_tool_discovery_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusModelsSteamCompatibilityToolDiscoveryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_models_steam_compatibility_tool_discovery_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusModelsSteamCompatibilityToolDiscovery), 0, (GInstanceInitFunc) proton_plus_models_steam_compatibility_tool_discovery_instance_init, NULL };
	GType proton_plus_models_steam_compatibility_tool_discovery_type_id;
	proton_plus_models_steam_compatibility_tool_discovery_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusModelsSteamCompatibilityToolDiscovery", &g_define_type_info, 0);
	ProtonPlusModelsSteamCompatibilityToolDiscovery_private_offset = g_type_add_instance_private (proton_plus_models_steam_compatibility_tool_discovery_type_id, sizeof (ProtonPlusModelsSteamCompatibilityToolDiscoveryPrivate));
	return proton_plus_models_steam_compatibility_tool_discovery_type_id;
}

GType
proton_plus_models_steam_compatibility_tool_discovery_get_type (void)
{
	static volatile gsize proton_plus_models_steam_compatibility_tool_discovery_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_models_steam_compatibility_tool_discovery_type_id__once)) {
		GType proton_plus_models_steam_compatibility_tool_discovery_type_id;
		proton_plus_models_steam_compatibility_tool_discovery_type_id = proton_plus_models_steam_compatibility_tool_discovery_get_type_once ();
		g_once_init_leave (&proton_plus_models_steam_compatibility_tool_discovery_type_id__once, proton_plus_models_steam_compatibility_tool_discovery_type_id);
	}
	return proton_plus_models_steam_compatibility_tool_discovery_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 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;
}

