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

/*
 * Copyright (C) 2011 Collabora Ltd.
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *       Raul Gutierrez Segales <raul.gutierrez.segales@collabora.co.uk>
 */

#include <glib.h>
#include <glib-object.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gio/gio.h>


#define FOLKS_TYPE_MATCH_RESULT (folks_match_result_get_type ())

#define FOLKS_TYPE_POTENTIAL_MATCH (folks_potential_match_get_type ())
#define FOLKS_POTENTIAL_MATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_POTENTIAL_MATCH, FolksPotentialMatch))
#define FOLKS_POTENTIAL_MATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_TYPE_POTENTIAL_MATCH, FolksPotentialMatchClass))
#define FOLKS_IS_POTENTIAL_MATCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_POTENTIAL_MATCH))
#define FOLKS_IS_POTENTIAL_MATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_TYPE_POTENTIAL_MATCH))
#define FOLKS_POTENTIAL_MATCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_TYPE_POTENTIAL_MATCH, FolksPotentialMatchClass))

typedef struct _FolksPotentialMatch FolksPotentialMatch;
typedef struct _FolksPotentialMatchClass FolksPotentialMatchClass;
typedef struct _FolksPotentialMatchPrivate FolksPotentialMatchPrivate;

#define FOLKS_TYPE_INDIVIDUAL (folks_individual_get_type ())
#define FOLKS_INDIVIDUAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_INDIVIDUAL, FolksIndividual))
#define FOLKS_INDIVIDUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_TYPE_INDIVIDUAL, FolksIndividualClass))
#define FOLKS_IS_INDIVIDUAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_INDIVIDUAL))
#define FOLKS_IS_INDIVIDUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_TYPE_INDIVIDUAL))
#define FOLKS_INDIVIDUAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_TYPE_INDIVIDUAL, FolksIndividualClass))

typedef struct _FolksIndividual FolksIndividual;
typedef struct _FolksIndividualClass FolksIndividualClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define FOLKS_TYPE_TRUST_LEVEL (folks_trust_level_get_type ())

#define FOLKS_TYPE_GENDER_DETAILS (folks_gender_details_get_type ())
#define FOLKS_GENDER_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_GENDER_DETAILS, FolksGenderDetails))
#define FOLKS_IS_GENDER_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_GENDER_DETAILS))
#define FOLKS_GENDER_DETAILS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), FOLKS_TYPE_GENDER_DETAILS, FolksGenderDetailsIface))

typedef struct _FolksGenderDetails FolksGenderDetails;
typedef struct _FolksGenderDetailsIface FolksGenderDetailsIface;

#define FOLKS_TYPE_GENDER (folks_gender_get_type ())

#define FOLKS_TYPE_PHONE_DETAILS (folks_phone_details_get_type ())
#define FOLKS_PHONE_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_PHONE_DETAILS, FolksPhoneDetails))
#define FOLKS_IS_PHONE_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_PHONE_DETAILS))
#define FOLKS_PHONE_DETAILS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), FOLKS_TYPE_PHONE_DETAILS, FolksPhoneDetailsIface))

typedef struct _FolksPhoneDetails FolksPhoneDetails;
typedef struct _FolksPhoneDetailsIface FolksPhoneDetailsIface;

#define FOLKS_TYPE_ABSTRACT_FIELD_DETAILS (folks_abstract_field_details_get_type ())
#define FOLKS_ABSTRACT_FIELD_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_ABSTRACT_FIELD_DETAILS, FolksAbstractFieldDetails))
#define FOLKS_ABSTRACT_FIELD_DETAILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_TYPE_ABSTRACT_FIELD_DETAILS, FolksAbstractFieldDetailsClass))
#define FOLKS_IS_ABSTRACT_FIELD_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_ABSTRACT_FIELD_DETAILS))
#define FOLKS_IS_ABSTRACT_FIELD_DETAILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_TYPE_ABSTRACT_FIELD_DETAILS))
#define FOLKS_ABSTRACT_FIELD_DETAILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_TYPE_ABSTRACT_FIELD_DETAILS, FolksAbstractFieldDetailsClass))

typedef struct _FolksAbstractFieldDetails FolksAbstractFieldDetails;
typedef struct _FolksAbstractFieldDetailsClass FolksAbstractFieldDetailsClass;

#define FOLKS_TYPE_PHONE_FIELD_DETAILS (folks_phone_field_details_get_type ())
#define FOLKS_PHONE_FIELD_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_PHONE_FIELD_DETAILS, FolksPhoneFieldDetails))
#define FOLKS_PHONE_FIELD_DETAILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_TYPE_PHONE_FIELD_DETAILS, FolksPhoneFieldDetailsClass))
#define FOLKS_IS_PHONE_FIELD_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_PHONE_FIELD_DETAILS))
#define FOLKS_IS_PHONE_FIELD_DETAILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_TYPE_PHONE_FIELD_DETAILS))
#define FOLKS_PHONE_FIELD_DETAILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_TYPE_PHONE_FIELD_DETAILS, FolksPhoneFieldDetailsClass))

typedef struct _FolksPhoneFieldDetails FolksPhoneFieldDetails;
typedef struct _FolksPhoneFieldDetailsClass FolksPhoneFieldDetailsClass;

#define FOLKS_TYPE_NAME_DETAILS (folks_name_details_get_type ())
#define FOLKS_NAME_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_NAME_DETAILS, FolksNameDetails))
#define FOLKS_IS_NAME_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_NAME_DETAILS))
#define FOLKS_NAME_DETAILS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), FOLKS_TYPE_NAME_DETAILS, FolksNameDetailsIface))

typedef struct _FolksNameDetails FolksNameDetails;
typedef struct _FolksNameDetailsIface FolksNameDetailsIface;

#define FOLKS_TYPE_STRUCTURED_NAME (folks_structured_name_get_type ())
#define FOLKS_STRUCTURED_NAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_STRUCTURED_NAME, FolksStructuredName))
#define FOLKS_STRUCTURED_NAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_TYPE_STRUCTURED_NAME, FolksStructuredNameClass))
#define FOLKS_IS_STRUCTURED_NAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_STRUCTURED_NAME))
#define FOLKS_IS_STRUCTURED_NAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_TYPE_STRUCTURED_NAME))
#define FOLKS_STRUCTURED_NAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_TYPE_STRUCTURED_NAME, FolksStructuredNameClass))

typedef struct _FolksStructuredName FolksStructuredName;
typedef struct _FolksStructuredNameClass FolksStructuredNameClass;

#define FOLKS_TYPE_ALIAS_DETAILS (folks_alias_details_get_type ())
#define FOLKS_ALIAS_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_ALIAS_DETAILS, FolksAliasDetails))
#define FOLKS_IS_ALIAS_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_ALIAS_DETAILS))
#define FOLKS_ALIAS_DETAILS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), FOLKS_TYPE_ALIAS_DETAILS, FolksAliasDetailsIface))

typedef struct _FolksAliasDetails FolksAliasDetails;
typedef struct _FolksAliasDetailsIface FolksAliasDetailsIface;

#define FOLKS_TYPE_IM_DETAILS (folks_im_details_get_type ())
#define FOLKS_IM_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_IM_DETAILS, FolksImDetails))
#define FOLKS_IS_IM_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_IM_DETAILS))
#define FOLKS_IM_DETAILS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), FOLKS_TYPE_IM_DETAILS, FolksImDetailsIface))

typedef struct _FolksImDetails FolksImDetails;
typedef struct _FolksImDetailsIface FolksImDetailsIface;

#define FOLKS_TYPE_IM_FIELD_DETAILS (folks_im_field_details_get_type ())
#define FOLKS_IM_FIELD_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_IM_FIELD_DETAILS, FolksImFieldDetails))
#define FOLKS_IM_FIELD_DETAILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_TYPE_IM_FIELD_DETAILS, FolksImFieldDetailsClass))
#define FOLKS_IS_IM_FIELD_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_IM_FIELD_DETAILS))
#define FOLKS_IS_IM_FIELD_DETAILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_TYPE_IM_FIELD_DETAILS))
#define FOLKS_IM_FIELD_DETAILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_TYPE_IM_FIELD_DETAILS, FolksImFieldDetailsClass))

typedef struct _FolksImFieldDetails FolksImFieldDetails;
typedef struct _FolksImFieldDetailsClass FolksImFieldDetailsClass;

#define FOLKS_TYPE_EMAIL_DETAILS (folks_email_details_get_type ())
#define FOLKS_EMAIL_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_EMAIL_DETAILS, FolksEmailDetails))
#define FOLKS_IS_EMAIL_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_EMAIL_DETAILS))
#define FOLKS_EMAIL_DETAILS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), FOLKS_TYPE_EMAIL_DETAILS, FolksEmailDetailsIface))

typedef struct _FolksEmailDetails FolksEmailDetails;
typedef struct _FolksEmailDetailsIface FolksEmailDetailsIface;

#define FOLKS_TYPE_EMAIL_FIELD_DETAILS (folks_email_field_details_get_type ())
#define FOLKS_EMAIL_FIELD_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_EMAIL_FIELD_DETAILS, FolksEmailFieldDetails))
#define FOLKS_EMAIL_FIELD_DETAILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_TYPE_EMAIL_FIELD_DETAILS, FolksEmailFieldDetailsClass))
#define FOLKS_IS_EMAIL_FIELD_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_EMAIL_FIELD_DETAILS))
#define FOLKS_IS_EMAIL_FIELD_DETAILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_TYPE_EMAIL_FIELD_DETAILS))
#define FOLKS_EMAIL_FIELD_DETAILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_TYPE_EMAIL_FIELD_DETAILS, FolksEmailFieldDetailsClass))

typedef struct _FolksEmailFieldDetails FolksEmailFieldDetails;
typedef struct _FolksEmailFieldDetailsClass FolksEmailFieldDetailsClass;

typedef enum  {
	FOLKS_MATCH_RESULT_NONE = -1,
	FOLKS_MATCH_RESULT_VERY_LOW = 0,
	FOLKS_MATCH_RESULT_LOW = 1,
	FOLKS_MATCH_RESULT_MEDIUM = 2,
	FOLKS_MATCH_RESULT_HIGH = 3,
	FOLKS_MATCH_RESULT_VERY_HIGH = 4,
	FOLKS_MATCH_RESULT_MIN = FOLKS_MATCH_RESULT_NONE,
	FOLKS_MATCH_RESULT_MAX = FOLKS_MATCH_RESULT_VERY_HIGH
} FolksMatchResult;

struct _FolksPotentialMatch {
	GObject parent_instance;
	FolksPotentialMatchPrivate * priv;
};

struct _FolksPotentialMatchClass {
	GObjectClass parent_class;
};

struct _FolksPotentialMatchPrivate {
	FolksMatchResult _result;
	FolksIndividual* _individual_a;
	FolksIndividual* _individual_b;
};

typedef enum  {
	FOLKS_TRUST_LEVEL_NONE,
	FOLKS_TRUST_LEVEL_PERSONAS
} FolksTrustLevel;

typedef enum  {
	FOLKS_GENDER_UNSPECIFIED,
	FOLKS_GENDER_MALE,
	FOLKS_GENDER_FEMALE
} FolksGender;

typedef enum  {
	FOLKS_PROPERTY_ERROR_NOT_WRITEABLE,
	FOLKS_PROPERTY_ERROR_INVALID_VALUE,
	FOLKS_PROPERTY_ERROR_UNKNOWN_ERROR
} FolksPropertyError;
#define FOLKS_PROPERTY_ERROR folks_property_error_quark ()
struct _FolksGenderDetailsIface {
	GTypeInterface parent_iface;
	void (*change_gender) (FolksGenderDetails* self, FolksGender gender, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*change_gender_finish) (FolksGenderDetails* self, GAsyncResult* _res_, GError** error);
	FolksGender (*get_gender) (FolksGenderDetails* self);
	void (*set_gender) (FolksGenderDetails* self, FolksGender value);
};

struct _FolksPhoneDetailsIface {
	GTypeInterface parent_iface;
	void (*change_phone_numbers) (FolksPhoneDetails* self, GeeSet* phone_numbers, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*change_phone_numbers_finish) (FolksPhoneDetails* self, GAsyncResult* _res_, GError** error);
	GeeSet* (*get_phone_numbers) (FolksPhoneDetails* self);
	void (*set_phone_numbers) (FolksPhoneDetails* self, GeeSet* value);
};

struct _FolksNameDetailsIface {
	GTypeInterface parent_iface;
	void (*change_structured_name) (FolksNameDetails* self, FolksStructuredName* name, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*change_structured_name_finish) (FolksNameDetails* self, GAsyncResult* _res_, GError** error);
	void (*change_full_name) (FolksNameDetails* self, const gchar* full_name, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*change_full_name_finish) (FolksNameDetails* self, GAsyncResult* _res_, GError** error);
	void (*change_nickname) (FolksNameDetails* self, const gchar* nickname, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*change_nickname_finish) (FolksNameDetails* self, GAsyncResult* _res_, GError** error);
	FolksStructuredName* (*get_structured_name) (FolksNameDetails* self);
	void (*set_structured_name) (FolksNameDetails* self, FolksStructuredName* value);
	const gchar* (*get_full_name) (FolksNameDetails* self);
	void (*set_full_name) (FolksNameDetails* self, const gchar* value);
	const gchar* (*get_nickname) (FolksNameDetails* self);
	void (*set_nickname) (FolksNameDetails* self, const gchar* value);
};

struct _FolksAliasDetailsIface {
	GTypeInterface parent_iface;
	void (*change_alias) (FolksAliasDetails* self, const gchar* alias, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*change_alias_finish) (FolksAliasDetails* self, GAsyncResult* _res_, GError** error);
	const gchar* (*get_alias) (FolksAliasDetails* self);
	void (*set_alias) (FolksAliasDetails* self, const gchar* value);
};

struct _FolksImDetailsIface {
	GTypeInterface parent_iface;
	void (*change_im_addresses) (FolksImDetails* self, GeeMultiMap* im_addresses, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*change_im_addresses_finish) (FolksImDetails* self, GAsyncResult* _res_, GError** error);
	GeeMultiMap* (*get_im_addresses) (FolksImDetails* self);
	void (*set_im_addresses) (FolksImDetails* self, GeeMultiMap* value);
};

struct _FolksEmailDetailsIface {
	GTypeInterface parent_iface;
	void (*change_email_addresses) (FolksEmailDetails* self, GeeSet* email_addresses, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*change_email_addresses_finish) (FolksEmailDetails* self, GAsyncResult* _res_, GError** error);
	GeeSet* (*get_email_addresses) (FolksEmailDetails* self);
	void (*set_email_addresses) (FolksEmailDetails* self, GeeSet* value);
};


static gpointer folks_potential_match_parent_class = NULL;
extern GeeSet* folks_potential_match_known_email_aliases;
GeeSet* folks_potential_match_known_email_aliases = NULL;
static gdouble folks_potential_match__DIST_THRESHOLD;
static gdouble folks_potential_match__DIST_THRESHOLD = 0.70;

GType folks_match_result_get_type (void) G_GNUC_CONST;
GType folks_potential_match_get_type (void) G_GNUC_CONST;
GType folks_individual_get_type (void) G_GNUC_CONST;
#define FOLKS_POTENTIAL_MATCH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), FOLKS_TYPE_POTENTIAL_MATCH, FolksPotentialMatchPrivate))
enum  {
	FOLKS_POTENTIAL_MATCH_DUMMY_PROPERTY
};
#define FOLKS_POTENTIAL_MATCH__SEPARATORS "._-+"
FolksMatchResult folks_potential_match_potential_match (FolksPotentialMatch* self, FolksIndividual* a, FolksIndividual* b);
GType folks_trust_level_get_type (void) G_GNUC_CONST;
FolksTrustLevel folks_individual_get_trust_level (FolksIndividual* self);
GType folks_gender_get_type (void) G_GNUC_CONST;
GQuark folks_property_error_quark (void);
GType folks_gender_details_get_type (void) G_GNUC_CONST;
FolksGender folks_gender_details_get_gender (FolksGenderDetails* self);
static void _folks_potential_match_inspect_im_addresses (FolksPotentialMatch* self);
static void _folks_potential_match_inspect_emails (FolksPotentialMatch* self);
static void _folks_potential_match_inspect_phone_numbers (FolksPotentialMatch* self);
static void _folks_potential_match_name_similarity (FolksPotentialMatch* self);
GType folks_abstract_field_details_get_type (void) G_GNUC_CONST;
GType folks_phone_field_details_get_type (void) G_GNUC_CONST;
GType folks_phone_details_get_type (void) G_GNUC_CONST;
GeeSet* folks_phone_details_get_phone_numbers (FolksPhoneDetails* self);
gboolean folks_abstract_field_details_values_equal (FolksAbstractFieldDetails* self, FolksAbstractFieldDetails* that);
static gboolean _folks_potential_match_look_alike (FolksPotentialMatch* self, const gchar* a, const gchar* b);
GType folks_structured_name_get_type (void) G_GNUC_CONST;
GType folks_name_details_get_type (void) G_GNUC_CONST;
const gchar* folks_name_details_get_nickname (FolksNameDetails* self);
static gboolean _folks_potential_match_look_alike_or_identical (FolksPotentialMatch* self, const gchar* a, const gchar* b, gboolean* exact);
const gchar* folks_name_details_get_full_name (FolksNameDetails* self);
GType folks_alias_details_get_type (void) G_GNUC_CONST;
const gchar* folks_alias_details_get_alias (FolksAliasDetails* self);
FolksStructuredName* folks_name_details_get_structured_name (FolksNameDetails* self);
gboolean folks_structured_name_is_empty (FolksStructuredName* self);
gboolean folks_structured_name_equal (FolksStructuredName* self, FolksStructuredName* other);
gboolean _folks_utils_str_equal_safe (const gchar* a, const gchar* b);
const gchar* folks_structured_name_get_given_name (FolksStructuredName* self);
const gchar* folks_structured_name_get_family_name (FolksStructuredName* self);
const gchar* folks_structured_name_get_additional_names (FolksStructuredName* self);
const gchar* folks_structured_name_get_prefixes (FolksStructuredName* self);
const gchar* folks_structured_name_get_suffixes (FolksStructuredName* self);
static FolksMatchResult _folks_potential_match_inc_match_level (FolksPotentialMatch* self, FolksMatchResult current_level, gint times);
GType folks_im_field_details_get_type (void) G_GNUC_CONST;
GType folks_im_details_get_type (void) G_GNUC_CONST;
GeeMultiMap* folks_im_details_get_im_addresses (FolksImDetails* self);
gconstpointer folks_abstract_field_details_get_value (FolksAbstractFieldDetails* self);
GType folks_email_field_details_get_type (void) G_GNUC_CONST;
GType folks_email_details_get_type (void) G_GNUC_CONST;
GeeSet* folks_email_details_get_email_addresses (FolksEmailDetails* self);
static gboolean _folks_potential_match_check_initials_expansion (FolksPotentialMatch* self, gchar** tokens_a, int tokens_a_length1, gchar** tokens_b, int tokens_b_length1);
static gboolean _folks_potential_match_match_tokens (FolksPotentialMatch* self, gchar** tokens_a, int tokens_a_length1, gchar** tokens_b, int tokens_b_length1);
static gboolean _folks_potential_match_do_check_initials_expansion (FolksPotentialMatch* self, gchar** expanded_name, int expanded_name_length1, const gchar* initials);
static gboolean _folks_potential_match_do_match_tokens (FolksPotentialMatch* self, gchar** bigger_set, int bigger_set_length1, gchar** smaller_set, int smaller_set_length1);
static gdouble folks_potential_match_jaro_dist (FolksPotentialMatch* self, const gchar* s1, const gchar* s2);
static gint _folks_potential_match_matches (FolksPotentialMatch* self, const gchar* s1, const gchar* s2, gint max_dist, gdouble* t);
static gunichar _folks_potential_match_stripped_char (FolksPotentialMatch* self, gunichar ch);
static gint _folks_potential_match_contains (FolksPotentialMatch* self, const gchar* haystack, gunichar c, gint pos, gint max_dist);
FolksPotentialMatch* folks_potential_match_new (void);
FolksPotentialMatch* folks_potential_match_construct (GType object_type);
static void folks_potential_match_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


/**
 * Likely-ness of a potential match.
 *
 * Note that the order should be maintained.
 *
 * @since 0.5.0
 */
GType folks_match_result_get_type (void) {
	static volatile gsize folks_match_result_type_id__volatile = 0;
	if (g_once_init_enter (&folks_match_result_type_id__volatile)) {
		static const GEnumValue values[] = {{FOLKS_MATCH_RESULT_NONE, "FOLKS_MATCH_RESULT_NONE", "none"}, {FOLKS_MATCH_RESULT_VERY_LOW, "FOLKS_MATCH_RESULT_VERY_LOW", "very-low"}, {FOLKS_MATCH_RESULT_LOW, "FOLKS_MATCH_RESULT_LOW", "low"}, {FOLKS_MATCH_RESULT_MEDIUM, "FOLKS_MATCH_RESULT_MEDIUM", "medium"}, {FOLKS_MATCH_RESULT_HIGH, "FOLKS_MATCH_RESULT_HIGH", "high"}, {FOLKS_MATCH_RESULT_VERY_HIGH, "FOLKS_MATCH_RESULT_VERY_HIGH", "very-high"}, {FOLKS_MATCH_RESULT_MIN, "FOLKS_MATCH_RESULT_MIN", "min"}, {FOLKS_MATCH_RESULT_MAX, "FOLKS_MATCH_RESULT_MAX", "max"}, {0, NULL, NULL}};
		GType folks_match_result_type_id;
		folks_match_result_type_id = g_enum_register_static ("FolksMatchResult", values);
		g_once_init_leave (&folks_match_result_type_id__volatile, folks_match_result_type_id);
	}
	return folks_match_result_type_id__volatile;
}


/**
   * Whether two individuals are likely to be the same person.
   *
   * @param a an individual to compare
   * @param b another individual to compare
   *
   * @since 0.5.0
   */
static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


FolksMatchResult folks_potential_match_potential_match (FolksPotentialMatch* self, FolksIndividual* a, FolksIndividual* b) {
	FolksMatchResult result = 0;
	FolksIndividual* _tmp0_;
	FolksIndividual* _tmp1_;
	FolksIndividual* _tmp2_;
	FolksIndividual* _tmp3_;
	gboolean _tmp4_ = FALSE;
	FolksIndividual* _tmp5_;
	FolksTrustLevel _tmp6_;
	FolksTrustLevel _tmp7_;
	gboolean _tmp11_;
	gboolean _tmp13_ = FALSE;
	gboolean _tmp14_ = FALSE;
	FolksIndividual* _tmp15_;
	FolksGender _tmp16_;
	FolksGender _tmp17_;
	gboolean _tmp21_;
	gboolean _tmp28_;
	FolksMatchResult _tmp30_;
	FolksMatchResult _tmp32_;
	FolksMatchResult _tmp34_;
	FolksMatchResult _tmp36_;
	FolksMatchResult _tmp38_;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (a != NULL, 0);
	g_return_val_if_fail (b != NULL, 0);
	_tmp0_ = a;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_individual_a);
	self->priv->_individual_a = _tmp1_;
	_tmp2_ = b;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 (self->priv->_individual_b);
	self->priv->_individual_b = _tmp3_;
	self->priv->_result = FOLKS_MATCH_RESULT_MIN;
	_tmp5_ = a;
	_tmp6_ = folks_individual_get_trust_level (_tmp5_);
	_tmp7_ = _tmp6_;
	if (_tmp7_ == FOLKS_TRUST_LEVEL_NONE) {
		_tmp4_ = TRUE;
	} else {
		FolksIndividual* _tmp8_;
		FolksTrustLevel _tmp9_;
		FolksTrustLevel _tmp10_;
		_tmp8_ = b;
		_tmp9_ = folks_individual_get_trust_level (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp4_ = _tmp10_ == FOLKS_TRUST_LEVEL_NONE;
	}
	_tmp11_ = _tmp4_;
	if (_tmp11_) {
		FolksMatchResult _tmp12_;
		_tmp12_ = self->priv->_result;
		result = _tmp12_;
		return result;
	}
	self->priv->_result = FOLKS_MATCH_RESULT_VERY_LOW;
	_tmp15_ = self->priv->_individual_a;
	_tmp16_ = folks_gender_details_get_gender ((FolksGenderDetails*) _tmp15_);
	_tmp17_ = _tmp16_;
	if (_tmp17_ != FOLKS_GENDER_UNSPECIFIED) {
		FolksIndividual* _tmp18_;
		FolksGender _tmp19_;
		FolksGender _tmp20_;
		_tmp18_ = self->priv->_individual_b;
		_tmp19_ = folks_gender_details_get_gender ((FolksGenderDetails*) _tmp18_);
		_tmp20_ = _tmp19_;
		_tmp14_ = _tmp20_ != FOLKS_GENDER_UNSPECIFIED;
	} else {
		_tmp14_ = FALSE;
	}
	_tmp21_ = _tmp14_;
	if (_tmp21_) {
		FolksIndividual* _tmp22_;
		FolksGender _tmp23_;
		FolksGender _tmp24_;
		FolksIndividual* _tmp25_;
		FolksGender _tmp26_;
		FolksGender _tmp27_;
		_tmp22_ = self->priv->_individual_a;
		_tmp23_ = folks_gender_details_get_gender ((FolksGenderDetails*) _tmp22_);
		_tmp24_ = _tmp23_;
		_tmp25_ = self->priv->_individual_b;
		_tmp26_ = folks_gender_details_get_gender ((FolksGenderDetails*) _tmp25_);
		_tmp27_ = _tmp26_;
		_tmp13_ = _tmp24_ != _tmp27_;
	} else {
		_tmp13_ = FALSE;
	}
	_tmp28_ = _tmp13_;
	if (_tmp28_) {
		FolksMatchResult _tmp29_;
		_tmp29_ = self->priv->_result;
		result = _tmp29_;
		return result;
	}
	_folks_potential_match_inspect_im_addresses (self);
	_tmp30_ = self->priv->_result;
	if (_tmp30_ == FOLKS_MATCH_RESULT_MAX) {
		FolksMatchResult _tmp31_;
		_tmp31_ = self->priv->_result;
		result = _tmp31_;
		return result;
	}
	_folks_potential_match_inspect_emails (self);
	_tmp32_ = self->priv->_result;
	if (_tmp32_ == FOLKS_MATCH_RESULT_MAX) {
		FolksMatchResult _tmp33_;
		_tmp33_ = self->priv->_result;
		result = _tmp33_;
		return result;
	}
	_folks_potential_match_inspect_phone_numbers (self);
	_tmp34_ = self->priv->_result;
	if (_tmp34_ == FOLKS_MATCH_RESULT_MAX) {
		FolksMatchResult _tmp35_;
		_tmp35_ = self->priv->_result;
		result = _tmp35_;
		return result;
	}
	_folks_potential_match_name_similarity (self);
	_tmp36_ = self->priv->_result;
	if (_tmp36_ == FOLKS_MATCH_RESULT_MAX) {
		FolksMatchResult _tmp37_;
		_tmp37_ = self->priv->_result;
		result = _tmp37_;
		return result;
	}
	_tmp38_ = self->priv->_result;
	result = _tmp38_;
	return result;
}


static void _folks_potential_match_inspect_phone_numbers (FolksPotentialMatch* self) {
	FolksIndividual* _tmp0_;
	GeeSet* _tmp1_;
	GeeSet* _tmp2_;
	GeeSet* _tmp3_;
	GeeSet* set_a;
	FolksIndividual* _tmp4_;
	GeeSet* _tmp5_;
	GeeSet* _tmp6_;
	GeeSet* _tmp7_;
	GeeSet* set_b;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_individual_a;
	_tmp1_ = folks_phone_details_get_phone_numbers ((FolksPhoneDetails*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	set_a = _tmp3_;
	_tmp4_ = self->priv->_individual_b;
	_tmp5_ = folks_phone_details_get_phone_numbers ((FolksPhoneDetails*) _tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = _g_object_ref0 (_tmp6_);
	set_b = _tmp7_;
	{
		GeeSet* _tmp8_;
		GeeIterator* _tmp9_ = NULL;
		GeeIterator* _phone_fd_a_it;
		_tmp8_ = set_a;
		_tmp9_ = gee_iterable_iterator ((GeeIterable*) _tmp8_);
		_phone_fd_a_it = _tmp9_;
		while (TRUE) {
			GeeIterator* _tmp10_;
			gboolean _tmp11_ = FALSE;
			GeeIterator* _tmp12_;
			gpointer _tmp13_ = NULL;
			FolksPhoneFieldDetails* phone_fd_a;
			_tmp10_ = _phone_fd_a_it;
			_tmp11_ = gee_iterator_next (_tmp10_);
			if (!_tmp11_) {
				break;
			}
			_tmp12_ = _phone_fd_a_it;
			_tmp13_ = gee_iterator_get (_tmp12_);
			phone_fd_a = (FolksPhoneFieldDetails*) _tmp13_;
			{
				GeeSet* _tmp14_;
				GeeIterator* _tmp15_ = NULL;
				GeeIterator* _phone_fd_b_it;
				_tmp14_ = set_b;
				_tmp15_ = gee_iterable_iterator ((GeeIterable*) _tmp14_);
				_phone_fd_b_it = _tmp15_;
				while (TRUE) {
					GeeIterator* _tmp16_;
					gboolean _tmp17_ = FALSE;
					GeeIterator* _tmp18_;
					gpointer _tmp19_ = NULL;
					FolksPhoneFieldDetails* phone_fd_b;
					FolksPhoneFieldDetails* _tmp20_;
					FolksPhoneFieldDetails* _tmp21_;
					gboolean _tmp22_ = FALSE;
					_tmp16_ = _phone_fd_b_it;
					_tmp17_ = gee_iterator_next (_tmp16_);
					if (!_tmp17_) {
						break;
					}
					_tmp18_ = _phone_fd_b_it;
					_tmp19_ = gee_iterator_get (_tmp18_);
					phone_fd_b = (FolksPhoneFieldDetails*) _tmp19_;
					_tmp20_ = phone_fd_a;
					_tmp21_ = phone_fd_b;
					_tmp22_ = folks_abstract_field_details_values_equal ((FolksAbstractFieldDetails*) _tmp20_, (FolksAbstractFieldDetails*) _tmp21_);
					if (_tmp22_) {
						self->priv->_result = FOLKS_MATCH_RESULT_HIGH;
						_g_object_unref0 (phone_fd_b);
						_g_object_unref0 (_phone_fd_b_it);
						_g_object_unref0 (phone_fd_a);
						_g_object_unref0 (_phone_fd_a_it);
						_g_object_unref0 (set_b);
						_g_object_unref0 (set_a);
						return;
					}
					_g_object_unref0 (phone_fd_b);
				}
				_g_object_unref0 (_phone_fd_b_it);
			}
			_g_object_unref0 (phone_fd_a);
		}
		_g_object_unref0 (_phone_fd_a_it);
	}
	_g_object_unref0 (set_b);
	_g_object_unref0 (set_a);
}


static void _folks_potential_match_name_similarity (FolksPotentialMatch* self) {
	gdouble similarity;
	gboolean exact_match;
	FolksIndividual* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	FolksIndividual* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp10_ = FALSE;
	FolksIndividual* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	FolksIndividual* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	gboolean _tmp17_ = FALSE;
	gboolean _tmp18_ = FALSE;
	gboolean _tmp27_;
	gboolean _tmp36_;
	gboolean _tmp45_;
	FolksIndividual* _tmp47_;
	FolksStructuredName* _tmp48_;
	FolksStructuredName* _tmp49_;
	FolksStructuredName* _tmp50_;
	FolksStructuredName* _a;
	FolksIndividual* _tmp51_;
	FolksStructuredName* _tmp52_;
	FolksStructuredName* _tmp53_;
	FolksStructuredName* _tmp54_;
	FolksStructuredName* _b;
	gboolean _tmp55_ = FALSE;
	FolksStructuredName* _tmp56_;
	gboolean _tmp58_;
	gdouble _tmp119_;
	gdouble _tmp120_;
	gdouble _tmp121_;
	g_return_if_fail (self != NULL);
	similarity = 0.0;
	exact_match = FALSE;
	_tmp0_ = self->priv->_individual_a;
	_tmp1_ = folks_name_details_get_nickname ((FolksNameDetails*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->_individual_b;
	_tmp4_ = folks_name_details_get_nickname ((FolksNameDetails*) _tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _folks_potential_match_look_alike (self, _tmp2_, _tmp5_);
	if (_tmp6_) {
		gdouble _tmp7_;
		_tmp7_ = similarity;
		similarity = _tmp7_ + 0.20;
	}
	_tmp11_ = self->priv->_individual_a;
	_tmp12_ = folks_name_details_get_full_name ((FolksNameDetails*) _tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = self->priv->_individual_b;
	_tmp15_ = folks_name_details_get_full_name ((FolksNameDetails*) _tmp14_);
	_tmp16_ = _tmp15_;
	_tmp18_ = _folks_potential_match_look_alike_or_identical (self, _tmp13_, _tmp16_, &_tmp17_);
	exact_match = _tmp17_;
	if (_tmp18_) {
		_tmp10_ = TRUE;
	} else {
		FolksIndividual* _tmp19_;
		const gchar* _tmp20_;
		const gchar* _tmp21_;
		FolksIndividual* _tmp22_;
		const gchar* _tmp23_;
		const gchar* _tmp24_;
		gboolean _tmp25_ = FALSE;
		gboolean _tmp26_ = FALSE;
		_tmp19_ = self->priv->_individual_a;
		_tmp20_ = folks_alias_details_get_alias ((FolksAliasDetails*) _tmp19_);
		_tmp21_ = _tmp20_;
		_tmp22_ = self->priv->_individual_b;
		_tmp23_ = folks_name_details_get_full_name ((FolksNameDetails*) _tmp22_);
		_tmp24_ = _tmp23_;
		_tmp26_ = _folks_potential_match_look_alike_or_identical (self, _tmp21_, _tmp24_, &_tmp25_);
		exact_match = _tmp25_;
		_tmp10_ = _tmp26_;
	}
	_tmp27_ = _tmp10_;
	if (_tmp27_) {
		_tmp9_ = TRUE;
	} else {
		FolksIndividual* _tmp28_;
		const gchar* _tmp29_;
		const gchar* _tmp30_;
		FolksIndividual* _tmp31_;
		const gchar* _tmp32_;
		const gchar* _tmp33_;
		gboolean _tmp34_ = FALSE;
		gboolean _tmp35_ = FALSE;
		_tmp28_ = self->priv->_individual_a;
		_tmp29_ = folks_name_details_get_full_name ((FolksNameDetails*) _tmp28_);
		_tmp30_ = _tmp29_;
		_tmp31_ = self->priv->_individual_b;
		_tmp32_ = folks_alias_details_get_alias ((FolksAliasDetails*) _tmp31_);
		_tmp33_ = _tmp32_;
		_tmp35_ = _folks_potential_match_look_alike_or_identical (self, _tmp30_, _tmp33_, &_tmp34_);
		exact_match = _tmp34_;
		_tmp9_ = _tmp35_;
	}
	_tmp36_ = _tmp9_;
	if (_tmp36_) {
		_tmp8_ = TRUE;
	} else {
		FolksIndividual* _tmp37_;
		const gchar* _tmp38_;
		const gchar* _tmp39_;
		FolksIndividual* _tmp40_;
		const gchar* _tmp41_;
		const gchar* _tmp42_;
		gboolean _tmp43_ = FALSE;
		gboolean _tmp44_ = FALSE;
		_tmp37_ = self->priv->_individual_a;
		_tmp38_ = folks_alias_details_get_alias ((FolksAliasDetails*) _tmp37_);
		_tmp39_ = _tmp38_;
		_tmp40_ = self->priv->_individual_b;
		_tmp41_ = folks_alias_details_get_alias ((FolksAliasDetails*) _tmp40_);
		_tmp42_ = _tmp41_;
		_tmp44_ = _folks_potential_match_look_alike_or_identical (self, _tmp39_, _tmp42_, &_tmp43_);
		exact_match = _tmp43_;
		_tmp8_ = _tmp44_;
	}
	_tmp45_ = _tmp8_;
	if (_tmp45_) {
		gdouble _tmp46_;
		_tmp46_ = similarity;
		similarity = _tmp46_ + 0.70;
	}
	_tmp47_ = self->priv->_individual_a;
	_tmp48_ = folks_name_details_get_structured_name ((FolksNameDetails*) _tmp47_);
	_tmp49_ = _tmp48_;
	_tmp50_ = _g_object_ref0 (_tmp49_);
	_a = _tmp50_;
	_tmp51_ = self->priv->_individual_b;
	_tmp52_ = folks_name_details_get_structured_name ((FolksNameDetails*) _tmp51_);
	_tmp53_ = _tmp52_;
	_tmp54_ = _g_object_ref0 (_tmp53_);
	_b = _tmp54_;
	_tmp56_ = _a;
	if (_tmp56_ != NULL) {
		FolksStructuredName* _tmp57_;
		_tmp57_ = _b;
		_tmp55_ = _tmp57_ != NULL;
	} else {
		_tmp55_ = FALSE;
	}
	_tmp58_ = _tmp55_;
	if (_tmp58_) {
		FolksStructuredName* _tmp59_;
		FolksStructuredName* _tmp60_;
		FolksStructuredName* a;
		FolksStructuredName* _tmp61_;
		FolksStructuredName* _tmp62_;
		FolksStructuredName* b;
		gboolean _tmp63_ = FALSE;
		FolksStructuredName* _tmp64_;
		gboolean _tmp65_ = FALSE;
		gboolean _tmp69_;
		FolksStructuredName* _tmp70_;
		const gchar* _tmp71_;
		const gchar* _tmp72_;
		FolksStructuredName* _tmp73_;
		const gchar* _tmp74_;
		const gchar* _tmp75_;
		gboolean _tmp76_ = FALSE;
		gboolean _tmp78_ = FALSE;
		FolksStructuredName* _tmp79_;
		const gchar* _tmp80_;
		const gchar* _tmp81_;
		FolksStructuredName* _tmp82_;
		const gchar* _tmp83_;
		const gchar* _tmp84_;
		gboolean _tmp85_ = FALSE;
		gboolean _tmp93_;
		FolksStructuredName* _tmp95_;
		const gchar* _tmp96_;
		const gchar* _tmp97_;
		FolksStructuredName* _tmp98_;
		const gchar* _tmp99_;
		const gchar* _tmp100_;
		gboolean _tmp101_ = FALSE;
		FolksStructuredName* _tmp103_;
		const gchar* _tmp104_;
		const gchar* _tmp105_;
		FolksStructuredName* _tmp106_;
		const gchar* _tmp107_;
		const gchar* _tmp108_;
		gboolean _tmp109_ = FALSE;
		FolksStructuredName* _tmp111_;
		const gchar* _tmp112_;
		const gchar* _tmp113_;
		FolksStructuredName* _tmp114_;
		const gchar* _tmp115_;
		const gchar* _tmp116_;
		gboolean _tmp117_ = FALSE;
		_tmp59_ = _a;
		_tmp60_ = _g_object_ref0 (FOLKS_STRUCTURED_NAME (_tmp59_));
		a = _tmp60_;
		_tmp61_ = _b;
		_tmp62_ = _g_object_ref0 (FOLKS_STRUCTURED_NAME (_tmp61_));
		b = _tmp62_;
		_tmp64_ = a;
		_tmp65_ = folks_structured_name_is_empty (_tmp64_);
		if (_tmp65_ == FALSE) {
			FolksStructuredName* _tmp66_;
			FolksStructuredName* _tmp67_;
			gboolean _tmp68_ = FALSE;
			_tmp66_ = a;
			_tmp67_ = b;
			_tmp68_ = folks_structured_name_equal (_tmp66_, _tmp67_);
			_tmp63_ = _tmp68_;
		} else {
			_tmp63_ = FALSE;
		}
		_tmp69_ = _tmp63_;
		if (_tmp69_) {
			self->priv->_result = FOLKS_MATCH_RESULT_HIGH;
			_g_object_unref0 (b);
			_g_object_unref0 (a);
			_g_object_unref0 (_b);
			_g_object_unref0 (_a);
			return;
		}
		_tmp70_ = a;
		_tmp71_ = folks_structured_name_get_given_name (_tmp70_);
		_tmp72_ = _tmp71_;
		_tmp73_ = b;
		_tmp74_ = folks_structured_name_get_given_name (_tmp73_);
		_tmp75_ = _tmp74_;
		_tmp76_ = _folks_utils_str_equal_safe (_tmp72_, _tmp75_);
		if (_tmp76_) {
			gdouble _tmp77_;
			_tmp77_ = similarity;
			similarity = _tmp77_ + 0.20;
		}
		_tmp79_ = a;
		_tmp80_ = folks_structured_name_get_family_name (_tmp79_);
		_tmp81_ = _tmp80_;
		_tmp82_ = b;
		_tmp83_ = folks_structured_name_get_family_name (_tmp82_);
		_tmp84_ = _tmp83_;
		_tmp85_ = _folks_potential_match_look_alike (self, _tmp81_, _tmp84_);
		if (_tmp85_) {
			FolksStructuredName* _tmp86_;
			const gchar* _tmp87_;
			const gchar* _tmp88_;
			FolksStructuredName* _tmp89_;
			const gchar* _tmp90_;
			const gchar* _tmp91_;
			gboolean _tmp92_ = FALSE;
			_tmp86_ = a;
			_tmp87_ = folks_structured_name_get_given_name (_tmp86_);
			_tmp88_ = _tmp87_;
			_tmp89_ = b;
			_tmp90_ = folks_structured_name_get_given_name (_tmp89_);
			_tmp91_ = _tmp90_;
			_tmp92_ = _folks_potential_match_look_alike (self, _tmp88_, _tmp91_);
			_tmp78_ = _tmp92_;
		} else {
			_tmp78_ = FALSE;
		}
		_tmp93_ = _tmp78_;
		if (_tmp93_) {
			gdouble _tmp94_;
			_tmp94_ = similarity;
			similarity = _tmp94_ + 0.40;
		}
		_tmp95_ = a;
		_tmp96_ = folks_structured_name_get_additional_names (_tmp95_);
		_tmp97_ = _tmp96_;
		_tmp98_ = b;
		_tmp99_ = folks_structured_name_get_additional_names (_tmp98_);
		_tmp100_ = _tmp99_;
		_tmp101_ = _folks_utils_str_equal_safe (_tmp97_, _tmp100_);
		if (_tmp101_) {
			gdouble _tmp102_;
			_tmp102_ = similarity;
			similarity = _tmp102_ + 0.5;
		}
		_tmp103_ = a;
		_tmp104_ = folks_structured_name_get_prefixes (_tmp103_);
		_tmp105_ = _tmp104_;
		_tmp106_ = b;
		_tmp107_ = folks_structured_name_get_prefixes (_tmp106_);
		_tmp108_ = _tmp107_;
		_tmp109_ = _folks_utils_str_equal_safe (_tmp105_, _tmp108_);
		if (_tmp109_) {
			gdouble _tmp110_;
			_tmp110_ = similarity;
			similarity = _tmp110_ + 0.5;
		}
		_tmp111_ = a;
		_tmp112_ = folks_structured_name_get_suffixes (_tmp111_);
		_tmp113_ = _tmp112_;
		_tmp114_ = b;
		_tmp115_ = folks_structured_name_get_suffixes (_tmp114_);
		_tmp116_ = _tmp115_;
		_tmp117_ = _folks_utils_str_equal_safe (_tmp113_, _tmp116_);
		if (_tmp117_) {
			gdouble _tmp118_;
			_tmp118_ = similarity;
			similarity = _tmp118_ + 0.5;
		}
		_g_object_unref0 (b);
		_g_object_unref0 (a);
	}
	_tmp119_ = similarity;
	g_debug ("potential-match.vala:250: [name_similarity] Got %f\n", _tmp119_);
	_tmp120_ = similarity;
	_tmp121_ = folks_potential_match__DIST_THRESHOLD;
	if (_tmp120_ >= _tmp121_) {
		gint inc;
		gboolean _tmp122_;
		FolksMatchResult _tmp124_;
		gint _tmp125_;
		FolksMatchResult _tmp126_ = 0;
		inc = 2;
		_tmp122_ = exact_match;
		if (_tmp122_) {
			gint _tmp123_;
			_tmp123_ = inc;
			inc = _tmp123_ + 1;
		}
		_tmp124_ = self->priv->_result;
		_tmp125_ = inc;
		_tmp126_ = _folks_potential_match_inc_match_level (self, _tmp124_, _tmp125_);
		self->priv->_result = _tmp126_;
	}
	_g_object_unref0 (_b);
	_g_object_unref0 (_a);
}


/**
   * Number of equal IM addresses between two individuals.
   *
   * This compares the addresses without comparing their associated protocols.
   *
   * @since 0.5.0
   */
static void _folks_potential_match_inspect_im_addresses (FolksPotentialMatch* self) {
	GeeHashSet* _tmp0_;
	GeeHashSet* addrs;
	g_return_if_fail (self != NULL);
	_tmp0_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL);
	addrs = _tmp0_;
	{
		FolksIndividual* _tmp1_;
		GeeMultiMap* _tmp2_;
		GeeMultiMap* _tmp3_;
		GeeCollection* _tmp4_ = NULL;
		GeeCollection* _tmp5_;
		GeeIterator* _tmp6_ = NULL;
		GeeIterator* _tmp7_;
		GeeIterator* _im_a_it;
		_tmp1_ = self->priv->_individual_a;
		_tmp2_ = folks_im_details_get_im_addresses ((FolksImDetails*) _tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_multi_map_get_values (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = gee_iterable_iterator ((GeeIterable*) _tmp5_);
		_tmp7_ = _tmp6_;
		_g_object_unref0 (_tmp5_);
		_im_a_it = _tmp7_;
		while (TRUE) {
			GeeIterator* _tmp8_;
			gboolean _tmp9_ = FALSE;
			GeeIterator* _tmp10_;
			gpointer _tmp11_ = NULL;
			FolksImFieldDetails* im_a;
			GeeHashSet* _tmp12_;
			FolksImFieldDetails* _tmp13_;
			gconstpointer _tmp14_;
			const gchar* _tmp15_;
			_tmp8_ = _im_a_it;
			_tmp9_ = gee_iterator_next (_tmp8_);
			if (!_tmp9_) {
				break;
			}
			_tmp10_ = _im_a_it;
			_tmp11_ = gee_iterator_get (_tmp10_);
			im_a = (FolksImFieldDetails*) _tmp11_;
			_tmp12_ = addrs;
			_tmp13_ = im_a;
			_tmp14_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) _tmp13_);
			_tmp15_ = _tmp14_;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp12_, (const gchar*) _tmp15_);
			_g_object_unref0 (im_a);
		}
		_g_object_unref0 (_im_a_it);
	}
	{
		FolksIndividual* _tmp16_;
		GeeMultiMap* _tmp17_;
		GeeMultiMap* _tmp18_;
		GeeCollection* _tmp19_ = NULL;
		GeeCollection* _tmp20_;
		GeeIterator* _tmp21_ = NULL;
		GeeIterator* _tmp22_;
		GeeIterator* _im_b_it;
		_tmp16_ = self->priv->_individual_b;
		_tmp17_ = folks_im_details_get_im_addresses ((FolksImDetails*) _tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = gee_multi_map_get_values (_tmp18_);
		_tmp20_ = _tmp19_;
		_tmp21_ = gee_iterable_iterator ((GeeIterable*) _tmp20_);
		_tmp22_ = _tmp21_;
		_g_object_unref0 (_tmp20_);
		_im_b_it = _tmp22_;
		while (TRUE) {
			GeeIterator* _tmp23_;
			gboolean _tmp24_ = FALSE;
			GeeIterator* _tmp25_;
			gpointer _tmp26_ = NULL;
			FolksImFieldDetails* im_b;
			GeeHashSet* _tmp27_;
			FolksImFieldDetails* _tmp28_;
			gconstpointer _tmp29_;
			const gchar* _tmp30_;
			gboolean _tmp31_ = FALSE;
			_tmp23_ = _im_b_it;
			_tmp24_ = gee_iterator_next (_tmp23_);
			if (!_tmp24_) {
				break;
			}
			_tmp25_ = _im_b_it;
			_tmp26_ = gee_iterator_get (_tmp25_);
			im_b = (FolksImFieldDetails*) _tmp26_;
			_tmp27_ = addrs;
			_tmp28_ = im_b;
			_tmp29_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) _tmp28_);
			_tmp30_ = _tmp29_;
			_tmp31_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp27_, (const gchar*) _tmp30_);
			if (_tmp31_ == TRUE) {
				self->priv->_result = FOLKS_MATCH_RESULT_HIGH;
				_g_object_unref0 (im_b);
				_g_object_unref0 (_im_b_it);
				_g_object_unref0 (addrs);
				return;
			}
			_g_object_unref0 (im_b);
		}
		_g_object_unref0 (_im_b_it);
	}
	_g_object_unref0 (addrs);
}


/**
   * Inspect email addresses.
   *
   * @since 0.5.0
   */
static void _folks_potential_match_inspect_emails (FolksPotentialMatch* self) {
	FolksIndividual* _tmp0_;
	GeeSet* _tmp1_;
	GeeSet* _tmp2_;
	GeeSet* _tmp3_;
	GeeSet* set_a;
	FolksIndividual* _tmp4_;
	GeeSet* _tmp5_;
	GeeSet* _tmp6_;
	GeeSet* _tmp7_;
	GeeSet* set_b;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_individual_a;
	_tmp1_ = folks_email_details_get_email_addresses ((FolksEmailDetails*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	set_a = _tmp3_;
	_tmp4_ = self->priv->_individual_b;
	_tmp5_ = folks_email_details_get_email_addresses ((FolksEmailDetails*) _tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = _g_object_ref0 (_tmp6_);
	set_b = _tmp7_;
	{
		GeeSet* _tmp8_;
		GeeIterator* _tmp9_ = NULL;
		GeeIterator* _fd_a_it;
		_tmp8_ = set_a;
		_tmp9_ = gee_iterable_iterator ((GeeIterable*) _tmp8_);
		_fd_a_it = _tmp9_;
		while (TRUE) {
			GeeIterator* _tmp10_;
			gboolean _tmp11_ = FALSE;
			GeeIterator* _tmp12_;
			gpointer _tmp13_ = NULL;
			FolksEmailFieldDetails* fd_a;
			FolksEmailFieldDetails* _tmp14_;
			gconstpointer _tmp15_;
			const gchar* _tmp16_;
			gchar** _tmp17_;
			gchar** _tmp18_ = NULL;
			gchar** email_split_a;
			gint email_split_a_length1;
			gint _email_split_a_size_;
			gchar** _tmp19_;
			gint _tmp19__length1;
			gchar** _tmp23_;
			gint _tmp23__length1;
			const gchar* _tmp24_;
			gchar** _tmp25_;
			gchar** _tmp26_ = NULL;
			gchar** tokens_a;
			gint tokens_a_length1;
			gint _tokens_a_size_;
			_tmp10_ = _fd_a_it;
			_tmp11_ = gee_iterator_next (_tmp10_);
			if (!_tmp11_) {
				break;
			}
			_tmp12_ = _fd_a_it;
			_tmp13_ = gee_iterator_get (_tmp12_);
			fd_a = (FolksEmailFieldDetails*) _tmp13_;
			_tmp14_ = fd_a;
			_tmp15_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) _tmp14_);
			_tmp16_ = _tmp15_;
			_tmp18_ = _tmp17_ = g_strsplit ((const gchar*) _tmp16_, "@", 0);
			email_split_a = _tmp18_;
			email_split_a_length1 = _vala_array_length (_tmp17_);
			_email_split_a_size_ = email_split_a_length1;
			_tmp19_ = email_split_a;
			_tmp19__length1 = email_split_a_length1;
			if (_tmp19__length1 < 2) {
				FolksEmailFieldDetails* _tmp20_;
				gconstpointer _tmp21_;
				const gchar* _tmp22_;
				_tmp20_ = fd_a;
				_tmp21_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) _tmp20_);
				_tmp22_ = _tmp21_;
				g_warning ("Invalid e-mail address when looking for potential " "match: %s", (const gchar*) _tmp22_);
				email_split_a = (_vala_array_free (email_split_a, email_split_a_length1, (GDestroyNotify) g_free), NULL);
				_g_object_unref0 (fd_a);
				continue;
			}
			_tmp23_ = email_split_a;
			_tmp23__length1 = email_split_a_length1;
			_tmp24_ = _tmp23_[0];
			_tmp26_ = _tmp25_ = g_strsplit_set (_tmp24_, FOLKS_POTENTIAL_MATCH__SEPARATORS, 0);
			tokens_a = _tmp26_;
			tokens_a_length1 = _vala_array_length (_tmp25_);
			_tokens_a_size_ = tokens_a_length1;
			{
				GeeSet* _tmp27_;
				GeeIterator* _tmp28_ = NULL;
				GeeIterator* _fd_b_it;
				_tmp27_ = set_b;
				_tmp28_ = gee_iterable_iterator ((GeeIterable*) _tmp27_);
				_fd_b_it = _tmp28_;
				while (TRUE) {
					GeeIterator* _tmp29_;
					gboolean _tmp30_ = FALSE;
					GeeIterator* _tmp31_;
					gpointer _tmp32_ = NULL;
					FolksEmailFieldDetails* fd_b;
					FolksEmailFieldDetails* _tmp33_;
					gconstpointer _tmp34_;
					const gchar* _tmp35_;
					gchar** _tmp36_;
					gchar** _tmp37_ = NULL;
					gchar** email_split_b;
					gint email_split_b_length1;
					gint _email_split_b_size_;
					gchar** _tmp38_;
					gint _tmp38__length1;
					FolksEmailFieldDetails* _tmp42_;
					gconstpointer _tmp43_;
					const gchar* _tmp44_;
					FolksEmailFieldDetails* _tmp45_;
					gconstpointer _tmp46_;
					const gchar* _tmp47_;
					_tmp29_ = _fd_b_it;
					_tmp30_ = gee_iterator_next (_tmp29_);
					if (!_tmp30_) {
						break;
					}
					_tmp31_ = _fd_b_it;
					_tmp32_ = gee_iterator_get (_tmp31_);
					fd_b = (FolksEmailFieldDetails*) _tmp32_;
					_tmp33_ = fd_b;
					_tmp34_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) _tmp33_);
					_tmp35_ = _tmp34_;
					_tmp37_ = _tmp36_ = g_strsplit ((const gchar*) _tmp35_, "@", 0);
					email_split_b = _tmp37_;
					email_split_b_length1 = _vala_array_length (_tmp36_);
					_email_split_b_size_ = email_split_b_length1;
					_tmp38_ = email_split_b;
					_tmp38__length1 = email_split_b_length1;
					if (_tmp38__length1 < 2) {
						FolksEmailFieldDetails* _tmp39_;
						gconstpointer _tmp40_;
						const gchar* _tmp41_;
						_tmp39_ = fd_b;
						_tmp40_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) _tmp39_);
						_tmp41_ = _tmp40_;
						g_warning ("Invalid e-mail address when looking for " "potential match: %s", (const gchar*) _tmp41_);
						email_split_b = (_vala_array_free (email_split_b, email_split_b_length1, (GDestroyNotify) g_free), NULL);
						_g_object_unref0 (fd_b);
						continue;
					}
					_tmp42_ = fd_a;
					_tmp43_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) _tmp42_);
					_tmp44_ = _tmp43_;
					_tmp45_ = fd_b;
					_tmp46_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) _tmp45_);
					_tmp47_ = _tmp46_;
					if (g_strcmp0 ((const gchar*) _tmp44_, (const gchar*) _tmp47_) == 0) {
						GeeSet* _tmp48_;
						gchar** _tmp49_;
						gint _tmp49__length1;
						const gchar* _tmp50_;
						gboolean _tmp51_ = FALSE;
						_tmp48_ = folks_potential_match_known_email_aliases;
						_tmp49_ = email_split_a;
						_tmp49__length1 = email_split_a_length1;
						_tmp50_ = _tmp49_[0];
						_tmp51_ = gee_collection_contains ((GeeCollection*) _tmp48_, _tmp50_);
						if (_tmp51_ == TRUE) {
							FolksMatchResult _tmp52_;
							_tmp52_ = self->priv->_result;
							if (_tmp52_ < FOLKS_MATCH_RESULT_HIGH) {
								self->priv->_result = FOLKS_MATCH_RESULT_LOW;
							}
						} else {
							self->priv->_result = FOLKS_MATCH_RESULT_HIGH;
							email_split_b = (_vala_array_free (email_split_b, email_split_b_length1, (GDestroyNotify) g_free), NULL);
							_g_object_unref0 (fd_b);
							_g_object_unref0 (_fd_b_it);
							tokens_a = (_vala_array_free (tokens_a, tokens_a_length1, (GDestroyNotify) g_free), NULL);
							email_split_a = (_vala_array_free (email_split_a, email_split_a_length1, (GDestroyNotify) g_free), NULL);
							_g_object_unref0 (fd_a);
							_g_object_unref0 (_fd_a_it);
							_g_object_unref0 (set_b);
							_g_object_unref0 (set_a);
							return;
						}
					} else {
						gchar** _tmp53_;
						gint _tmp53__length1;
						const gchar* _tmp54_;
						gchar** _tmp55_;
						gchar** _tmp56_ = NULL;
						gchar** tokens_b;
						gint tokens_b_length1;
						gint _tokens_b_size_;
						gchar** _tmp57_;
						gint _tmp57__length1;
						gchar** _tmp58_;
						gint _tmp58__length1;
						gboolean _tmp59_ = FALSE;
						_tmp53_ = email_split_b;
						_tmp53__length1 = email_split_b_length1;
						_tmp54_ = _tmp53_[0];
						_tmp56_ = _tmp55_ = g_strsplit_set (_tmp54_, FOLKS_POTENTIAL_MATCH__SEPARATORS, 0);
						tokens_b = _tmp56_;
						tokens_b_length1 = _vala_array_length (_tmp55_);
						_tokens_b_size_ = tokens_b_length1;
						_tmp57_ = tokens_a;
						_tmp57__length1 = tokens_a_length1;
						_tmp58_ = tokens_b;
						_tmp58__length1 = tokens_b_length1;
						_tmp59_ = _folks_potential_match_check_initials_expansion (self, _tmp57_, _tmp57__length1, _tmp58_, _tmp58__length1);
						if (_tmp59_) {
							self->priv->_result = FOLKS_MATCH_RESULT_MEDIUM;
						} else {
							gchar** _tmp60_;
							gint _tmp60__length1;
							gchar** _tmp61_;
							gint _tmp61__length1;
							gboolean _tmp62_ = FALSE;
							_tmp60_ = tokens_a;
							_tmp60__length1 = tokens_a_length1;
							_tmp61_ = tokens_b;
							_tmp61__length1 = tokens_b_length1;
							_tmp62_ = _folks_potential_match_match_tokens (self, _tmp60_, _tmp60__length1, _tmp61_, _tmp61__length1);
							if (_tmp62_) {
								self->priv->_result = FOLKS_MATCH_RESULT_MEDIUM;
							}
						}
						tokens_b = (_vala_array_free (tokens_b, tokens_b_length1, (GDestroyNotify) g_free), NULL);
					}
					email_split_b = (_vala_array_free (email_split_b, email_split_b_length1, (GDestroyNotify) g_free), NULL);
					_g_object_unref0 (fd_b);
				}
				_g_object_unref0 (_fd_b_it);
			}
			tokens_a = (_vala_array_free (tokens_a, tokens_a_length1, (GDestroyNotify) g_free), NULL);
			email_split_a = (_vala_array_free (email_split_a, email_split_a_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (fd_a);
		}
		_g_object_unref0 (_fd_a_it);
	}
	_g_object_unref0 (set_b);
	_g_object_unref0 (set_a);
}


static gboolean _folks_potential_match_check_initials_expansion (FolksPotentialMatch* self, gchar** tokens_a, int tokens_a_length1, gchar** tokens_b, int tokens_b_length1) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	gchar** _tmp1_;
	gint _tmp1__length1;
	gchar** _tmp2_;
	gint _tmp2__length1;
	gboolean _tmp4_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = tokens_a;
	_tmp1__length1 = tokens_a_length1;
	_tmp2_ = tokens_b;
	_tmp2__length1 = tokens_b_length1;
	if (_tmp1__length1 > _tmp2__length1) {
		gchar** _tmp3_;
		gint _tmp3__length1;
		_tmp3_ = tokens_b;
		_tmp3__length1 = tokens_b_length1;
		_tmp0_ = _tmp3__length1 == 1;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp4_ = _tmp0_;
	if (_tmp4_) {
		gchar** _tmp5_;
		gint _tmp5__length1;
		gchar** _tmp6_;
		gint _tmp6__length1;
		const gchar* _tmp7_;
		gboolean _tmp8_ = FALSE;
		_tmp5_ = tokens_a;
		_tmp5__length1 = tokens_a_length1;
		_tmp6_ = tokens_b;
		_tmp6__length1 = tokens_b_length1;
		_tmp7_ = _tmp6_[0];
		_tmp8_ = _folks_potential_match_do_check_initials_expansion (self, _tmp5_, _tmp5__length1, _tmp7_);
		result = _tmp8_;
		return result;
	} else {
		gboolean _tmp9_ = FALSE;
		gchar** _tmp10_;
		gint _tmp10__length1;
		gchar** _tmp11_;
		gint _tmp11__length1;
		gboolean _tmp13_;
		_tmp10_ = tokens_b;
		_tmp10__length1 = tokens_b_length1;
		_tmp11_ = tokens_a;
		_tmp11__length1 = tokens_a_length1;
		if (_tmp10__length1 > _tmp11__length1) {
			gchar** _tmp12_;
			gint _tmp12__length1;
			_tmp12_ = tokens_a;
			_tmp12__length1 = tokens_a_length1;
			_tmp9_ = _tmp12__length1 == 1;
		} else {
			_tmp9_ = FALSE;
		}
		_tmp13_ = _tmp9_;
		if (_tmp13_) {
			gchar** _tmp14_;
			gint _tmp14__length1;
			gchar** _tmp15_;
			gint _tmp15__length1;
			const gchar* _tmp16_;
			gboolean _tmp17_ = FALSE;
			_tmp14_ = tokens_b;
			_tmp14__length1 = tokens_b_length1;
			_tmp15_ = tokens_a;
			_tmp15__length1 = tokens_a_length1;
			_tmp16_ = _tmp15_[0];
			_tmp17_ = _folks_potential_match_do_check_initials_expansion (self, _tmp14_, _tmp14__length1, _tmp16_);
			result = _tmp17_;
			return result;
		}
	}
	result = FALSE;
	return result;
}


static gchar string_get (const gchar* self, glong index) {
	gchar result = '\0';
	glong _tmp0_;
	gchar _tmp1_;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = index;
	_tmp1_ = ((gchar*) self)[_tmp0_];
	result = _tmp1_;
	return result;
}


static gboolean _folks_potential_match_do_check_initials_expansion (FolksPotentialMatch* self, gchar** expanded_name, int expanded_name_length1, const gchar* initials) {
	gboolean result = FALSE;
	gchar** _tmp0_;
	gint _tmp0__length1;
	const gchar* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (initials != NULL, FALSE);
	_tmp0_ = expanded_name;
	_tmp0__length1 = expanded_name_length1;
	_tmp1_ = initials;
	_tmp2_ = strlen (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp0__length1 != _tmp3_) {
		result = FALSE;
		return result;
	}
	{
		gint i;
		i = 0;
		{
			gboolean _tmp4_;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp5_;
				gint _tmp7_;
				gchar** _tmp8_;
				gint _tmp8__length1;
				gchar** _tmp9_;
				gint _tmp9__length1;
				gint _tmp10_;
				const gchar* _tmp11_;
				gchar _tmp12_ = '\0';
				const gchar* _tmp13_;
				gint _tmp14_;
				gchar _tmp15_ = '\0';
				_tmp5_ = _tmp4_;
				if (!_tmp5_) {
					gint _tmp6_;
					_tmp6_ = i;
					i = _tmp6_ + 1;
				}
				_tmp4_ = FALSE;
				_tmp7_ = i;
				_tmp8_ = expanded_name;
				_tmp8__length1 = expanded_name_length1;
				if (!(_tmp7_ < _tmp8__length1)) {
					break;
				}
				_tmp9_ = expanded_name;
				_tmp9__length1 = expanded_name_length1;
				_tmp10_ = i;
				_tmp11_ = _tmp9_[_tmp10_];
				_tmp12_ = string_get (_tmp11_, (glong) 0);
				_tmp13_ = initials;
				_tmp14_ = i;
				_tmp15_ = string_get (_tmp13_, (glong) _tmp14_);
				if (_tmp12_ != _tmp15_) {
					result = FALSE;
					return result;
				}
			}
		}
	}
	result = TRUE;
	return result;
}


static gboolean _folks_potential_match_match_tokens (FolksPotentialMatch* self, gchar** tokens_a, int tokens_a_length1, gchar** tokens_b, int tokens_b_length1) {
	gboolean result = FALSE;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = tokens_a;
	_tmp0__length1 = tokens_a_length1;
	_tmp1_ = tokens_b;
	_tmp1__length1 = tokens_b_length1;
	if (_tmp0__length1 > _tmp1__length1) {
		gchar** _tmp2_;
		gint _tmp2__length1;
		gchar** _tmp3_;
		gint _tmp3__length1;
		gboolean _tmp4_ = FALSE;
		_tmp2_ = tokens_a;
		_tmp2__length1 = tokens_a_length1;
		_tmp3_ = tokens_b;
		_tmp3__length1 = tokens_b_length1;
		_tmp4_ = _folks_potential_match_do_match_tokens (self, _tmp2_, _tmp2__length1, _tmp3_, _tmp3__length1);
		result = _tmp4_;
		return result;
	} else {
		gchar** _tmp5_;
		gint _tmp5__length1;
		gchar** _tmp6_;
		gint _tmp6__length1;
		gboolean _tmp7_ = FALSE;
		_tmp5_ = tokens_b;
		_tmp5__length1 = tokens_b_length1;
		_tmp6_ = tokens_a;
		_tmp6__length1 = tokens_a_length1;
		_tmp7_ = _folks_potential_match_do_match_tokens (self, _tmp5_, _tmp5__length1, _tmp6_, _tmp6__length1);
		result = _tmp7_;
		return result;
	}
}


static gboolean _folks_potential_match_do_match_tokens (FolksPotentialMatch* self, gchar** bigger_set, int bigger_set_length1, gchar** smaller_set, int smaller_set_length1) {
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	{
		gint i;
		i = 0;
		{
			gboolean _tmp0_;
			_tmp0_ = TRUE;
			while (TRUE) {
				gboolean _tmp1_;
				gint _tmp3_;
				gchar** _tmp4_;
				gint _tmp4__length1;
				_tmp1_ = _tmp0_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp3_ = i;
				_tmp4_ = smaller_set;
				_tmp4__length1 = smaller_set_length1;
				if (!(_tmp3_ < _tmp4__length1)) {
					break;
				}
				{
					gint j;
					j = 0;
					{
						gboolean _tmp5_;
						_tmp5_ = TRUE;
						while (TRUE) {
							gboolean _tmp6_;
							gint _tmp8_;
							gchar** _tmp9_;
							gint _tmp9__length1;
							gchar** _tmp10_;
							gint _tmp10__length1;
							gint _tmp11_;
							const gchar* _tmp12_;
							gchar** _tmp13_;
							gint _tmp13__length1;
							gint _tmp14_;
							const gchar* _tmp15_;
							_tmp6_ = _tmp5_;
							if (!_tmp6_) {
								gint _tmp7_;
								_tmp7_ = j;
								j = _tmp7_ + 1;
							}
							_tmp5_ = FALSE;
							_tmp8_ = j;
							_tmp9_ = bigger_set;
							_tmp9__length1 = bigger_set_length1;
							if (!(_tmp8_ < _tmp9__length1)) {
								break;
							}
							_tmp10_ = smaller_set;
							_tmp10__length1 = smaller_set_length1;
							_tmp11_ = i;
							_tmp12_ = _tmp10_[_tmp11_];
							_tmp13_ = bigger_set;
							_tmp13__length1 = bigger_set_length1;
							_tmp14_ = j;
							_tmp15_ = _tmp13_[_tmp14_];
							if (g_strcmp0 (_tmp12_, _tmp15_) == 0) {
								result = TRUE;
								return result;
							}
						}
					}
				}
			}
		}
	}
	result = FALSE;
	return result;
}


static FolksMatchResult _folks_potential_match_inc_match_level (FolksPotentialMatch* self, FolksMatchResult current_level, gint times) {
	FolksMatchResult result = 0;
	FolksMatchResult _tmp0_;
	gint _tmp1_;
	FolksMatchResult ret;
	FolksMatchResult _tmp2_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = current_level;
	_tmp1_ = times;
	ret = _tmp0_ + _tmp1_;
	_tmp2_ = ret;
	if (_tmp2_ > FOLKS_MATCH_RESULT_MAX) {
		ret = FOLKS_MATCH_RESULT_MAX;
	}
	result = ret;
	return result;
}


static gboolean _folks_potential_match_look_alike_or_identical (FolksPotentialMatch* self, const gchar* a, const gchar* b, gboolean* exact) {
	gboolean _vala_exact = FALSE;
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	const gchar* _tmp3_;
	gboolean _tmp5_;
	gboolean _tmp7_;
	gboolean _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	gdouble _tmp14_ = 0.0;
	gdouble _tmp15_;
	g_return_val_if_fail (self != NULL, FALSE);
	_vala_exact = FALSE;
	_tmp3_ = a;
	if (_tmp3_ == NULL) {
		_tmp2_ = TRUE;
	} else {
		const gchar* _tmp4_;
		_tmp4_ = a;
		_tmp2_ = g_strcmp0 (_tmp4_, "") == 0;
	}
	_tmp5_ = _tmp2_;
	if (_tmp5_) {
		_tmp1_ = TRUE;
	} else {
		const gchar* _tmp6_;
		_tmp6_ = b;
		_tmp1_ = _tmp6_ == NULL;
	}
	_tmp7_ = _tmp1_;
	if (_tmp7_) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp8_;
		_tmp8_ = b;
		_tmp0_ = g_strcmp0 (_tmp8_, "") == 0;
	}
	_tmp9_ = _tmp0_;
	if (_tmp9_) {
		result = FALSE;
		if (exact) {
			*exact = _vala_exact;
		}
		return result;
	}
	_tmp10_ = a;
	_tmp11_ = b;
	if (g_strcmp0 (_tmp10_, _tmp11_) == 0) {
		_vala_exact = TRUE;
		result = TRUE;
		if (exact) {
			*exact = _vala_exact;
		}
		return result;
	}
	_tmp12_ = a;
	_tmp13_ = b;
	_tmp14_ = folks_potential_match_jaro_dist (self, (const gchar*) _tmp12_, (const gchar*) _tmp13_);
	_tmp15_ = folks_potential_match__DIST_THRESHOLD;
	result = _tmp14_ >= _tmp15_;
	if (exact) {
		*exact = _vala_exact;
	}
	return result;
}


static gboolean _folks_potential_match_look_alike (FolksPotentialMatch* self, const gchar* a, const gchar* b) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	const gchar* _tmp3_;
	gboolean _tmp5_;
	gboolean _tmp7_;
	gboolean _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gdouble _tmp12_ = 0.0;
	gdouble _tmp13_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp3_ = a;
	if (_tmp3_ == NULL) {
		_tmp2_ = TRUE;
	} else {
		const gchar* _tmp4_;
		_tmp4_ = a;
		_tmp2_ = g_strcmp0 (_tmp4_, "") == 0;
	}
	_tmp5_ = _tmp2_;
	if (_tmp5_) {
		_tmp1_ = TRUE;
	} else {
		const gchar* _tmp6_;
		_tmp6_ = b;
		_tmp1_ = _tmp6_ == NULL;
	}
	_tmp7_ = _tmp1_;
	if (_tmp7_) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp8_;
		_tmp8_ = b;
		_tmp0_ = g_strcmp0 (_tmp8_, "") == 0;
	}
	_tmp9_ = _tmp0_;
	if (_tmp9_) {
		result = FALSE;
		return result;
	}
	_tmp10_ = a;
	_tmp11_ = b;
	_tmp12_ = folks_potential_match_jaro_dist (self, (const gchar*) _tmp10_, (const gchar*) _tmp11_);
	_tmp13_ = folks_potential_match__DIST_THRESHOLD;
	result = _tmp12_ >= _tmp13_;
	return result;
}


static gdouble folks_potential_match_jaro_dist (FolksPotentialMatch* self, const gchar* s1, const gchar* s2) {
	gdouble result = 0.0;
	gdouble distance = 0.0;
	gint _tmp0_ = 0;
	const gchar* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	gint _tmp13_;
	gint max;
	gint _tmp14_;
	gint max_dist;
	gdouble t = 0.0;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	gint _tmp17_;
	gdouble _tmp18_ = 0.0;
	gint _tmp19_ = 0;
	gdouble m;
	const gchar* _tmp20_;
	gint _tmp21_;
	gint _tmp22_;
	gdouble len_s1;
	const gchar* _tmp23_;
	gint _tmp24_;
	gint _tmp25_;
	gdouble len_s2;
	gdouble _tmp26_;
	gdouble _tmp27_;
	gdouble a;
	gdouble _tmp28_;
	gdouble _tmp29_;
	gdouble b;
	gdouble c;
	gdouble _tmp30_;
	gdouble _tmp34_;
	gdouble _tmp35_;
	gdouble _tmp36_;
	const gchar* _tmp37_;
	const gchar* _tmp38_;
	g_return_val_if_fail (self != NULL, 0.0);
	g_return_val_if_fail (s1 != NULL, 0.0);
	g_return_val_if_fail (s2 != NULL, 0.0);
	_tmp1_ = s1;
	_tmp2_ = strlen (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = s2;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	if (_tmp3_ > _tmp6_) {
		const gchar* _tmp7_;
		gint _tmp8_;
		gint _tmp9_;
		_tmp7_ = s1;
		_tmp8_ = strlen (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp0_ = _tmp9_;
	} else {
		const gchar* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		_tmp10_ = s2;
		_tmp11_ = strlen (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp0_ = _tmp12_;
	}
	_tmp13_ = _tmp0_;
	max = _tmp13_;
	_tmp14_ = max;
	max_dist = (_tmp14_ / 2) - 1;
	_tmp15_ = s1;
	_tmp16_ = s2;
	_tmp17_ = max_dist;
	_tmp19_ = _folks_potential_match_matches (self, _tmp15_, _tmp16_, _tmp17_, &_tmp18_);
	t = _tmp18_;
	m = (gdouble) _tmp19_;
	_tmp20_ = s1;
	_tmp21_ = strlen (_tmp20_);
	_tmp22_ = _tmp21_;
	len_s1 = (gdouble) _tmp22_;
	_tmp23_ = s2;
	_tmp24_ = strlen (_tmp23_);
	_tmp25_ = _tmp24_;
	len_s2 = (gdouble) _tmp25_;
	_tmp26_ = m;
	_tmp27_ = len_s1;
	a = _tmp26_ / _tmp27_;
	_tmp28_ = m;
	_tmp29_ = len_s2;
	b = _tmp28_ / _tmp29_;
	c = (gdouble) 0;
	_tmp30_ = m;
	if (((gint) _tmp30_) > 0) {
		gdouble _tmp31_;
		gdouble _tmp32_;
		gdouble _tmp33_;
		_tmp31_ = m;
		_tmp32_ = t;
		_tmp33_ = m;
		c = (_tmp31_ - _tmp32_) / _tmp33_;
	}
	_tmp34_ = a;
	_tmp35_ = b;
	_tmp36_ = c;
	distance = (1.0 / 3.0) * ((_tmp34_ + _tmp35_) + _tmp36_);
	_tmp37_ = s1;
	_tmp38_ = s2;
	g_debug ("potential-match.vala:494: [jaro_dist] Distance for %s and %s: %f\n", _tmp37_, _tmp38_, distance);
	result = distance;
	return result;
}


/**
   * stripped_char:
   *
   * Returns a stripped version of @ch, removing any case, accentuation
   * mark, or any special mark on it.
   *
   * Copied from Empathy's libempathy-gtk/empathy-live-search.c.
   *
   * Copyright (C) 2010 Collabora Ltd.
   * Copyright (C) 2007-2010 Nokia Corporation.
   *
   * Authors: Felix Kaser <felix.kaser@collabora.co.uk>
   *          Xavier Claessens <xavier.claessens@collabora.co.uk>
   *          Claudio Saavedra <csaavedra@igalia.com>
   */
static gunichar _folks_potential_match_stripped_char (FolksPotentialMatch* self, gunichar ch) {
	gunichar result = 0U;
	gunichar _tmp0_[1] = {0};
	gunichar retval[1];
	gunichar _tmp1_;
	GUnicodeType _tmp2_ = 0;
	GUnicodeType utype;
	GUnicodeType _tmp3_;
	gunichar _tmp7_;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_[0] = (gunichar) 0;
	memcpy (retval, _tmp0_, 1 * sizeof (gunichar));
	_tmp1_ = ch;
	_tmp2_ = g_unichar_type (_tmp1_);
	utype = _tmp2_;
	_tmp3_ = utype;
	switch (_tmp3_) {
		case G_UNICODE_CONTROL:
		case G_UNICODE_FORMAT:
		case G_UNICODE_UNASSIGNED:
		case G_UNICODE_NON_SPACING_MARK:
		case G_UNICODE_COMBINING_MARK:
		case G_UNICODE_ENCLOSING_MARK:
		{
			break;
		}
		default:
		case G_UNICODE_PRIVATE_USE:
		case G_UNICODE_SURROGATE:
		case G_UNICODE_LOWERCASE_LETTER:
		case G_UNICODE_MODIFIER_LETTER:
		case G_UNICODE_OTHER_LETTER:
		case G_UNICODE_TITLECASE_LETTER:
		case G_UNICODE_UPPERCASE_LETTER:
		case G_UNICODE_DECIMAL_NUMBER:
		case G_UNICODE_LETTER_NUMBER:
		case G_UNICODE_OTHER_NUMBER:
		case G_UNICODE_CONNECT_PUNCTUATION:
		case G_UNICODE_DASH_PUNCTUATION:
		case G_UNICODE_CLOSE_PUNCTUATION:
		case G_UNICODE_FINAL_PUNCTUATION:
		case G_UNICODE_INITIAL_PUNCTUATION:
		case G_UNICODE_OTHER_PUNCTUATION:
		case G_UNICODE_OPEN_PUNCTUATION:
		case G_UNICODE_CURRENCY_SYMBOL:
		case G_UNICODE_MODIFIER_SYMBOL:
		case G_UNICODE_MATH_SYMBOL:
		case G_UNICODE_OTHER_SYMBOL:
		case G_UNICODE_LINE_SEPARATOR:
		case G_UNICODE_PARAGRAPH_SEPARATOR:
		case G_UNICODE_SPACE_SEPARATOR:
		{
			gunichar _tmp4_;
			gunichar _tmp5_ = 0U;
			gunichar _tmp6_;
			_tmp4_ = ch;
			_tmp5_ = g_unichar_tolower (_tmp4_);
			ch = _tmp5_;
			_tmp6_ = ch;
			g_unichar_fully_decompose (_tmp6_, FALSE, retval, 1);
			break;
		}
	}
	_tmp7_ = retval[0];
	result = _tmp7_;
	return result;
}


static gboolean string_get_next_char (const gchar* self, gint* index, gunichar* c) {
	gunichar _vala_c = 0U;
	gboolean result = FALSE;
	gint _tmp0_;
	gunichar _tmp1_ = 0U;
	gunichar _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = *index;
	_tmp1_ = g_utf8_get_char (((gchar*) self) + _tmp0_);
	_vala_c = _tmp1_;
	_tmp2_ = _vala_c;
	if (_tmp2_ != ((gunichar) 0)) {
		gint _tmp3_;
		gchar* _tmp4_ = NULL;
		_tmp3_ = *index;
		_tmp4_ = g_utf8_next_char (((gchar*) self) + _tmp3_);
		*index = (gint) (_tmp4_ - ((gchar*) self));
		result = TRUE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	} else {
		result = FALSE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	}
	if (c) {
		*c = _vala_c;
	}
}


static gint _folks_potential_match_matches (FolksPotentialMatch* self, const gchar* s1, const gchar* s2, gint max_dist, gdouble* t) {
	gdouble _vala_t = 0.0;
	gint result = 0;
	gint matches;
	const gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	gboolean _tmp3_ = FALSE;
	gint idx;
	gunichar look_for;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	gint _tmp21_;
	gdouble _tmp22_;
	gdouble _tmp23_;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (s1 != NULL, 0);
	g_return_val_if_fail (s2 != NULL, 0);
	matches = 0;
	_vala_t = 0.0;
	_tmp0_ = s1;
	_tmp1_ = g_utf8_validate (_tmp0_, (gssize) (-1), NULL);
	g_assert (_tmp1_);
	_tmp2_ = s2;
	_tmp3_ = g_utf8_validate (_tmp2_, (gssize) (-1), NULL);
	g_assert (_tmp3_);
	idx = 0;
	look_for = (gunichar) 0;
	while (TRUE) {
		const gchar* _tmp4_;
		gunichar _tmp5_ = 0U;
		gboolean _tmp6_ = FALSE;
		gunichar _tmp7_;
		gunichar _tmp8_ = 0U;
		gunichar _tmp9_;
		const gchar* _tmp10_;
		gunichar _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		gint _tmp14_ = 0;
		gint contains;
		gint _tmp15_;
		_tmp4_ = s1;
		_tmp6_ = string_get_next_char (_tmp4_, &idx, &_tmp5_);
		look_for = _tmp5_;
		if (!_tmp6_) {
			break;
		}
		_tmp7_ = look_for;
		_tmp8_ = _folks_potential_match_stripped_char (self, _tmp7_);
		look_for = _tmp8_;
		_tmp9_ = look_for;
		if (_tmp9_ == ((gunichar) 0)) {
			continue;
		}
		_tmp10_ = s2;
		_tmp11_ = look_for;
		_tmp12_ = idx;
		_tmp13_ = max_dist;
		_tmp14_ = _folks_potential_match_contains (self, _tmp10_, _tmp11_, _tmp12_, _tmp13_);
		contains = _tmp14_;
		_tmp15_ = contains;
		if (_tmp15_ >= 0) {
			gint _tmp16_;
			gint _tmp17_;
			_tmp16_ = matches;
			matches = _tmp16_ + 1;
			_tmp17_ = contains;
			if (_tmp17_ > 0) {
				gdouble _tmp18_;
				_tmp18_ = _vala_t;
				_vala_t = _tmp18_ + 1.0;
			}
		}
	}
	_tmp19_ = s1;
	_tmp20_ = s2;
	_tmp21_ = matches;
	_tmp22_ = _vala_t;
	g_debug ("potential-match.vala:593: %s and %s have %d matches and %f / 2 transpo" \
"sitions\n", _tmp19_, _tmp20_, _tmp21_, _tmp22_);
	_tmp23_ = _vala_t;
	_vala_t = _tmp23_ / 2.0;
	result = matches;
	if (t) {
		*t = _vala_t;
	}
	return result;
}


static gunichar string_get_char (const gchar* self, glong index) {
	gunichar result = 0U;
	glong _tmp0_;
	gunichar _tmp1_ = 0U;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = index;
	_tmp1_ = g_utf8_get_char (((gchar*) self) + _tmp0_);
	result = _tmp1_;
	return result;
}


static gint _folks_potential_match_contains (FolksPotentialMatch* self, const gchar* haystack, gunichar c, gint pos, gint max_dist) {
	gint result = 0;
	const gchar* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint haystack_len;
	gboolean _tmp3_ = FALSE;
	gint _tmp4_;
	gint _tmp5_;
	gboolean _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	gint _tmp13_;
	gint _tmp14_ = 0;
	gint idx;
	gunichar ch;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (haystack != NULL, 0);
	_tmp0_ = haystack;
	_tmp1_ = strlen (_tmp0_);
	_tmp2_ = _tmp1_;
	haystack_len = _tmp2_;
	_tmp4_ = pos;
	_tmp5_ = haystack_len;
	if (_tmp4_ < _tmp5_) {
		const gchar* _tmp6_;
		gint _tmp7_;
		gunichar _tmp8_ = 0U;
		gunichar _tmp9_;
		_tmp6_ = haystack;
		_tmp7_ = pos;
		_tmp8_ = string_get_char (_tmp6_, (glong) _tmp7_);
		_tmp9_ = c;
		_tmp3_ = _tmp8_ == _tmp9_;
	} else {
		_tmp3_ = FALSE;
	}
	_tmp10_ = _tmp3_;
	if (_tmp10_) {
		result = 0;
		return result;
	}
	_tmp11_ = pos;
	_tmp12_ = max_dist;
	_tmp13_ = haystack_len;
	_tmp14_ = CLAMP (_tmp11_ - _tmp12_, 0, _tmp13_);
	idx = _tmp14_;
	ch = (gunichar) 0;
	while (TRUE) {
		gboolean _tmp15_ = FALSE;
		gint _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		gboolean _tmp22_;
		gunichar _tmp23_;
		gunichar _tmp24_ = 0U;
		gunichar _tmp25_;
		gunichar _tmp26_;
		gunichar _tmp27_;
		_tmp16_ = idx;
		_tmp17_ = pos;
		_tmp18_ = max_dist;
		if (_tmp16_ < (_tmp17_ + _tmp18_)) {
			const gchar* _tmp19_;
			gunichar _tmp20_ = 0U;
			gboolean _tmp21_ = FALSE;
			_tmp19_ = haystack;
			_tmp21_ = string_get_next_char (_tmp19_, &idx, &_tmp20_);
			ch = _tmp20_;
			_tmp15_ = _tmp21_;
		} else {
			_tmp15_ = FALSE;
		}
		_tmp22_ = _tmp15_;
		if (!_tmp22_) {
			break;
		}
		_tmp23_ = ch;
		_tmp24_ = _folks_potential_match_stripped_char (self, _tmp23_);
		ch = _tmp24_;
		_tmp25_ = ch;
		if (_tmp25_ == ((gunichar) 0)) {
			continue;
		}
		_tmp26_ = ch;
		_tmp27_ = c;
		if (_tmp26_ == _tmp27_) {
			gint _tmp28_;
			gint _tmp29_;
			gint _tmp30_ = 0;
			_tmp28_ = pos;
			_tmp29_ = idx;
			_tmp30_ = abs (_tmp28_ - _tmp29_);
			result = _tmp30_;
			return result;
		}
	}
	result = -1;
	return result;
}


FolksPotentialMatch* folks_potential_match_construct (GType object_type) {
	FolksPotentialMatch * self = NULL;
	self = (FolksPotentialMatch*) g_object_new (object_type, NULL);
	return self;
}


FolksPotentialMatch* folks_potential_match_new (void) {
	return folks_potential_match_construct (FOLKS_TYPE_POTENTIAL_MATCH);
}


static void folks_potential_match_class_init (FolksPotentialMatchClass * klass) {
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GeeHashSet* _tmp2_;
	GeeSet* _tmp3_;
	GeeSet* _tmp4_;
	GeeSet* _tmp5_;
	folks_potential_match_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (FolksPotentialMatchPrivate));
	G_OBJECT_CLASS (klass)->finalize = folks_potential_match_finalize;
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _tmp0_, _tmp1_);
	folks_potential_match_known_email_aliases = (GeeSet*) _tmp2_;
	_tmp3_ = folks_potential_match_known_email_aliases;
	gee_collection_add ((GeeCollection*) _tmp3_, "admin");
	_tmp4_ = folks_potential_match_known_email_aliases;
	gee_collection_add ((GeeCollection*) _tmp4_, "abuse");
	_tmp5_ = folks_potential_match_known_email_aliases;
	gee_collection_add ((GeeCollection*) _tmp5_, "webmaster");
}


static void folks_potential_match_instance_init (FolksPotentialMatch * self) {
	self->priv = FOLKS_POTENTIAL_MATCH_GET_PRIVATE (self);
}


static void folks_potential_match_finalize (GObject* obj) {
	FolksPotentialMatch * self;
	self = FOLKS_POTENTIAL_MATCH (obj);
	_g_object_unref0 (self->priv->_individual_a);
	_g_object_unref0 (self->priv->_individual_b);
	G_OBJECT_CLASS (folks_potential_match_parent_class)->finalize (obj);
}


/**
 * This class provides functionality to explore a potential match between
 * two individuals.
 *
 * @since 0.5.0
 */
GType folks_potential_match_get_type (void) {
	static volatile gsize folks_potential_match_type_id__volatile = 0;
	if (g_once_init_enter (&folks_potential_match_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (FolksPotentialMatchClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) folks_potential_match_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FolksPotentialMatch), 0, (GInstanceInitFunc) folks_potential_match_instance_init, NULL };
		GType folks_potential_match_type_id;
		folks_potential_match_type_id = g_type_register_static (G_TYPE_OBJECT, "FolksPotentialMatch", &g_define_type_info, 0);
		g_once_init_leave (&folks_potential_match_type_id__volatile, folks_potential_match_type_id);
	}
	return folks_potential_match_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


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



