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

#include <glib-object.h>
#include <glib.h>
#include <string.h>
#include <stdlib.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_FOO (foo_get_type ())
typedef struct _Foo Foo;

#define TYPE_BAR (bar_get_type ())
typedef struct _Bar Bar;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _Foo {
	gint i;
};

struct _Bar {
	gchar* s;
};

VALA_EXTERN Foo** foo_array;
VALA_EXTERN gint foo_array_length1;
Foo** foo_array = NULL;
gint foo_array_length1 = 0;
static gint _foo_array_size_ = 0;
VALA_EXTERN Bar** bar_array;
VALA_EXTERN gint bar_array_length1;
Bar** bar_array = NULL;
gint bar_array_length1 = 0;
static gint _bar_array_size_ = 0;

VALA_EXTERN GType foo_get_type (void) G_GNUC_CONST ;
VALA_EXTERN Foo* foo_dup (const Foo* self);
VALA_EXTERN void foo_free (Foo* self);
VALA_EXTERN Foo** foo_array_owned (gint* result_length1);
VALA_EXTERN Foo** foo_array_unowned (gint* result_length1);
VALA_EXTERN void test_without_destroy (void);
VALA_EXTERN GType bar_get_type (void) G_GNUC_CONST ;
VALA_EXTERN Bar* bar_dup (const Bar* self);
VALA_EXTERN void bar_free (Bar* self);
VALA_EXTERN void bar_copy (const Bar* self,
               Bar* dest);
VALA_EXTERN void bar_destroy (Bar* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (Bar, bar_destroy)
VALA_EXTERN Bar** bar_array_owned (gint* result_length1);
VALA_EXTERN Bar** bar_array_unowned (gint* result_length1);
VALA_EXTERN void test_with_destroy (void);
static void _vala_main (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);

Foo*
foo_dup (const Foo* self)
{
	Foo* dup;
	dup = g_new0 (Foo, 1);
	memcpy (dup, self, sizeof (Foo));
	return dup;
}

void
foo_free (Foo* self)
{
	g_free (self);
}

static GType
foo_get_type_once (void)
{
	GType foo_type_id;
	foo_type_id = g_boxed_type_register_static ("Foo", (GBoxedCopyFunc) foo_dup, (GBoxedFreeFunc) foo_free);
	return foo_type_id;
}

GType
foo_get_type (void)
{
	static volatile gsize foo_type_id__once = 0;
	if (g_once_init_enter (&foo_type_id__once)) {
		GType foo_type_id;
		foo_type_id = foo_get_type_once ();
		g_once_init_leave (&foo_type_id__once, foo_type_id);
	}
	return foo_type_id__once;
}

static gpointer
_foo_dup0 (gpointer self)
{
	return self ? foo_dup (self) : NULL;
}

Foo**
foo_array_owned (gint* result_length1)
{
	Foo _tmp0_ = {0};
	Foo* _tmp1_;
	Foo _tmp2_ = {0};
	Foo* _tmp3_;
	Foo _tmp4_ = {0};
	Foo* _tmp5_;
	Foo** _tmp6_;
	Foo** _tmp7_;
	gint _tmp7__length1;
	Foo** result;
	memset (&_tmp0_, 0, sizeof (Foo));
	_tmp0_.i = 23;
	_tmp1_ = _foo_dup0 (&_tmp0_);
	memset (&_tmp2_, 0, sizeof (Foo));
	_tmp2_.i = 42;
	_tmp3_ = _foo_dup0 (&_tmp2_);
	memset (&_tmp4_, 0, sizeof (Foo));
	_tmp4_.i = 4711;
	_tmp5_ = _foo_dup0 (&_tmp4_);
	_tmp6_ = g_new0 (Foo*, 3);
	_tmp6_[0] = _tmp1_;
	_tmp6_[1] = _tmp3_;
	_tmp6_[2] = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp7__length1 = 3;
	if (result_length1) {
		*result_length1 = _tmp7__length1;
	}
	result = _tmp7_;
	return result;
}

Foo**
foo_array_unowned (gint* result_length1)
{
	Foo _tmp0_ = {0};
	Foo* _tmp1_;
	Foo _tmp2_ = {0};
	Foo* _tmp3_;
	Foo _tmp4_ = {0};
	Foo* _tmp5_;
	Foo** _tmp6_;
	Foo** _tmp7_;
	gint _tmp7__length1;
	Foo** _tmp8_;
	gint _tmp8__length1;
	Foo** result;
	memset (&_tmp0_, 0, sizeof (Foo));
	_tmp0_.i = 23;
	_tmp1_ = _foo_dup0 (&_tmp0_);
	memset (&_tmp2_, 0, sizeof (Foo));
	_tmp2_.i = 42;
	_tmp3_ = _foo_dup0 (&_tmp2_);
	memset (&_tmp4_, 0, sizeof (Foo));
	_tmp4_.i = 4711;
	_tmp5_ = _foo_dup0 (&_tmp4_);
	_tmp6_ = g_new0 (Foo*, 3);
	_tmp6_[0] = _tmp1_;
	_tmp6_[1] = _tmp3_;
	_tmp6_[2] = _tmp5_;
	foo_array = (_vala_array_free (foo_array, foo_array_length1, (GDestroyNotify) foo_free), NULL);
	foo_array = _tmp6_;
	foo_array_length1 = 3;
	_foo_array_size_ = foo_array_length1;
	_tmp7_ = foo_array;
	_tmp7__length1 = foo_array_length1;
	_tmp8_ = _tmp7_;
	_tmp8__length1 = _tmp7__length1;
	if (result_length1) {
		*result_length1 = _tmp8__length1;
	}
	result = _tmp8_;
	return result;
}

void
test_without_destroy (void)
{
	{
		Foo** foo = NULL;
		Foo _tmp0_ = {0};
		Foo* _tmp1_;
		Foo _tmp2_ = {0};
		Foo* _tmp3_;
		Foo _tmp4_ = {0};
		Foo* _tmp5_;
		Foo** _tmp6_;
		gint foo_length1;
		gint _foo_size_;
		memset (&_tmp0_, 0, sizeof (Foo));
		_tmp0_.i = 23;
		_tmp1_ = _foo_dup0 (&_tmp0_);
		memset (&_tmp2_, 0, sizeof (Foo));
		_tmp2_.i = 42;
		_tmp3_ = _foo_dup0 (&_tmp2_);
		memset (&_tmp4_, 0, sizeof (Foo));
		_tmp4_.i = 4711;
		_tmp5_ = _foo_dup0 (&_tmp4_);
		_tmp6_ = g_new0 (Foo*, 3);
		_tmp6_[0] = _tmp1_;
		_tmp6_[1] = _tmp3_;
		_tmp6_[2] = _tmp5_;
		foo = _tmp6_;
		foo_length1 = 3;
		_foo_size_ = foo_length1;
		{
			Foo f = {0};
			Foo* _tmp7_;
			Foo _tmp8_;
			Foo* _tmp9_;
			_tmp7_ = foo[0];
			f = *_tmp7_;
			_tmp8_ = f;
			_vala_assert (_tmp8_.i == 23, "f.i == 23");
			_tmp9_ = foo[0];
			_vala_assert ((*_tmp9_).i == 23, "foo[0].i == 23");
		}
		{
			Foo f = {0};
			Foo* _tmp10_;
			Foo _tmp11_;
			Foo* _tmp12_;
			_tmp10_ = foo[1];
			f = (Foo) (*_tmp10_);
			_tmp11_ = f;
			_vala_assert (_tmp11_.i == 42, "f.i == 42");
			_tmp12_ = foo[1];
			_vala_assert ((*_tmp12_).i == 42, "foo[1].i == 42");
		}
		{
			Foo f = {0};
			Foo* _tmp13_;
			Foo _tmp14_;
			Foo* _tmp15_;
			_tmp13_ = foo[2];
			f = (Foo) (*_tmp13_);
			_tmp14_ = f;
			_vala_assert (_tmp14_.i == 4711, "f.i == 4711");
			_tmp15_ = foo[2];
			_vala_assert ((*_tmp15_).i == 4711, "foo[2].i == 4711");
		}
		foo = (_vala_array_free (foo, foo_length1, (GDestroyNotify) foo_free), NULL);
	}
	{
		Foo f = {0};
		gint _tmp16_ = 0;
		Foo** _tmp17_;
		Foo** _tmp18_;
		gint _tmp18__length1;
		Foo* _tmp19_;
		Foo _tmp20_;
		Foo _tmp21_;
		_tmp17_ = foo_array_owned (&_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp18__length1 = _tmp16_;
		_tmp19_ = _tmp18_[0];
		_tmp20_ = *_tmp19_;
		_tmp18_ = (_vala_array_free (_tmp18_, _tmp18__length1, (GDestroyNotify) foo_free), NULL);
		f = _tmp20_;
		_tmp21_ = f;
		_vala_assert (_tmp21_.i == 23, "f.i == 23");
	}
	{
		Foo f = {0};
		gint _tmp22_ = 0;
		Foo** _tmp23_;
		Foo** _tmp24_;
		gint _tmp24__length1;
		Foo* _tmp25_;
		Foo _tmp26_;
		Foo _tmp27_;
		_tmp23_ = foo_array_owned (&_tmp22_);
		_tmp24_ = _tmp23_;
		_tmp24__length1 = _tmp22_;
		_tmp25_ = _tmp24_[1];
		_tmp26_ = (Foo) (*_tmp25_);
		_tmp24_ = (_vala_array_free (_tmp24_, _tmp24__length1, (GDestroyNotify) foo_free), NULL);
		f = _tmp26_;
		_tmp27_ = f;
		_vala_assert (_tmp27_.i == 42, "f.i == 42");
	}
	{
		Foo f = {0};
		gint _tmp28_ = 0;
		Foo** _tmp29_;
		Foo** _tmp30_;
		gint _tmp30__length1;
		Foo* _tmp31_;
		Foo _tmp32_;
		Foo _tmp33_;
		_tmp29_ = foo_array_owned (&_tmp28_);
		_tmp30_ = _tmp29_;
		_tmp30__length1 = _tmp28_;
		_tmp31_ = _tmp30_[2];
		_tmp32_ = (Foo) (*_tmp31_);
		_tmp30_ = (_vala_array_free (_tmp30_, _tmp30__length1, (GDestroyNotify) foo_free), NULL);
		f = _tmp32_;
		_tmp33_ = f;
		_vala_assert (_tmp33_.i == 4711, "f.i == 4711");
	}
	{
		Foo f = {0};
		gint _tmp34_ = 0;
		Foo** _tmp35_;
		Foo* _tmp36_;
		Foo _tmp37_;
		_tmp35_ = foo_array_unowned (&_tmp34_);
		_tmp36_ = _tmp35_[0];
		f = *_tmp36_;
		_tmp37_ = f;
		_vala_assert (_tmp37_.i == 23, "f.i == 23");
	}
	{
		Foo f = {0};
		gint _tmp38_ = 0;
		Foo** _tmp39_;
		Foo* _tmp40_;
		Foo _tmp41_;
		_tmp39_ = foo_array_unowned (&_tmp38_);
		_tmp40_ = _tmp39_[1];
		f = (Foo) (*_tmp40_);
		_tmp41_ = f;
		_vala_assert (_tmp41_.i == 42, "f.i == 42");
	}
	{
		Foo f = {0};
		gint _tmp42_ = 0;
		Foo** _tmp43_;
		Foo* _tmp44_;
		Foo _tmp45_;
		_tmp43_ = foo_array_unowned (&_tmp42_);
		_tmp44_ = _tmp43_[2];
		f = (Foo) (*_tmp44_);
		_tmp45_ = f;
		_vala_assert (_tmp45_.i == 4711, "f.i == 4711");
	}
}

void
bar_copy (const Bar* self,
          Bar* dest)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	_tmp0_ = (*self).s;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).s);
	(*dest).s = _tmp1_;
}

void
bar_destroy (Bar* self)
{
	_g_free0 ((*self).s);
}

Bar*
bar_dup (const Bar* self)
{
	Bar* dup;
	dup = g_new0 (Bar, 1);
	bar_copy (self, dup);
	return dup;
}

void
bar_free (Bar* self)
{
	bar_destroy (self);
	g_free (self);
}

static GType
bar_get_type_once (void)
{
	GType bar_type_id;
	bar_type_id = g_boxed_type_register_static ("Bar", (GBoxedCopyFunc) bar_dup, (GBoxedFreeFunc) bar_free);
	return bar_type_id;
}

GType
bar_get_type (void)
{
	static volatile gsize bar_type_id__once = 0;
	if (g_once_init_enter (&bar_type_id__once)) {
		GType bar_type_id;
		bar_type_id = bar_get_type_once ();
		g_once_init_leave (&bar_type_id__once, bar_type_id);
	}
	return bar_type_id__once;
}

static gpointer
_bar_dup0 (gpointer self)
{
	return self ? bar_dup (self) : NULL;
}

Bar**
bar_array_owned (gint* result_length1)
{
	gchar* _tmp0_;
	Bar _tmp1_ = {0};
	Bar _tmp2_;
	Bar* _tmp3_;
	gchar* _tmp4_;
	Bar _tmp5_ = {0};
	Bar _tmp6_;
	Bar* _tmp7_;
	gchar* _tmp8_;
	Bar _tmp9_ = {0};
	Bar _tmp10_;
	Bar* _tmp11_;
	Bar** _tmp12_;
	Bar** _tmp13_;
	gint _tmp13__length1;
	Bar** _tmp14_;
	gint _tmp14__length1;
	Bar** result;
	_tmp0_ = g_strdup ("foo");
	memset (&_tmp1_, 0, sizeof (Bar));
	_g_free0 (_tmp1_.s);
	_tmp1_.s = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = _bar_dup0 (&_tmp2_);
	_tmp4_ = g_strdup ("bar");
	memset (&_tmp5_, 0, sizeof (Bar));
	_g_free0 (_tmp5_.s);
	_tmp5_.s = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp7_ = _bar_dup0 (&_tmp6_);
	_tmp8_ = g_strdup ("manam");
	memset (&_tmp9_, 0, sizeof (Bar));
	_g_free0 (_tmp9_.s);
	_tmp9_.s = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp11_ = _bar_dup0 (&_tmp10_);
	_tmp12_ = g_new0 (Bar*, 3);
	_tmp12_[0] = _tmp3_;
	_tmp12_[1] = _tmp7_;
	_tmp12_[2] = _tmp11_;
	_tmp13_ = _tmp12_;
	_tmp13__length1 = 3;
	bar_destroy (&_tmp10_);
	bar_destroy (&_tmp6_);
	bar_destroy (&_tmp2_);
	_tmp14_ = _tmp13_;
	_tmp14__length1 = _tmp13__length1;
	if (result_length1) {
		*result_length1 = _tmp14__length1;
	}
	result = _tmp14_;
	return result;
}

Bar**
bar_array_unowned (gint* result_length1)
{
	gchar* _tmp0_;
	Bar _tmp1_ = {0};
	Bar _tmp2_;
	Bar* _tmp3_;
	gchar* _tmp4_;
	Bar _tmp5_ = {0};
	Bar _tmp6_;
	Bar* _tmp7_;
	gchar* _tmp8_;
	Bar _tmp9_ = {0};
	Bar _tmp10_;
	Bar* _tmp11_;
	Bar** _tmp12_;
	Bar** _tmp13_;
	gint _tmp13__length1;
	Bar** _tmp14_;
	gint _tmp14__length1;
	Bar** result;
	_tmp0_ = g_strdup ("foo");
	memset (&_tmp1_, 0, sizeof (Bar));
	_g_free0 (_tmp1_.s);
	_tmp1_.s = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = _bar_dup0 (&_tmp2_);
	_tmp4_ = g_strdup ("bar");
	memset (&_tmp5_, 0, sizeof (Bar));
	_g_free0 (_tmp5_.s);
	_tmp5_.s = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp7_ = _bar_dup0 (&_tmp6_);
	_tmp8_ = g_strdup ("manam");
	memset (&_tmp9_, 0, sizeof (Bar));
	_g_free0 (_tmp9_.s);
	_tmp9_.s = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp11_ = _bar_dup0 (&_tmp10_);
	_tmp12_ = g_new0 (Bar*, 3);
	_tmp12_[0] = _tmp3_;
	_tmp12_[1] = _tmp7_;
	_tmp12_[2] = _tmp11_;
	bar_array = (_vala_array_free (bar_array, bar_array_length1, (GDestroyNotify) bar_free), NULL);
	bar_array = _tmp12_;
	bar_array_length1 = 3;
	_bar_array_size_ = bar_array_length1;
	bar_destroy (&_tmp10_);
	bar_destroy (&_tmp6_);
	bar_destroy (&_tmp2_);
	_tmp13_ = bar_array;
	_tmp13__length1 = bar_array_length1;
	_tmp14_ = _tmp13_;
	_tmp14__length1 = _tmp13__length1;
	if (result_length1) {
		*result_length1 = _tmp14__length1;
	}
	result = _tmp14_;
	return result;
}

void
test_with_destroy (void)
{
	{
		Bar** bar = NULL;
		gchar* _tmp0_;
		Bar _tmp1_ = {0};
		Bar _tmp2_;
		Bar* _tmp3_;
		gchar* _tmp4_;
		Bar _tmp5_ = {0};
		Bar _tmp6_;
		Bar* _tmp7_;
		gchar* _tmp8_;
		Bar _tmp9_ = {0};
		Bar _tmp10_;
		Bar* _tmp11_;
		Bar** _tmp12_;
		Bar** _tmp13_;
		gint _tmp13__length1;
		gint bar_length1;
		gint _bar_size_;
		_tmp0_ = g_strdup ("foo");
		memset (&_tmp1_, 0, sizeof (Bar));
		_g_free0 (_tmp1_.s);
		_tmp1_.s = _tmp0_;
		_tmp2_ = _tmp1_;
		_tmp3_ = _bar_dup0 (&_tmp2_);
		_tmp4_ = g_strdup ("bar");
		memset (&_tmp5_, 0, sizeof (Bar));
		_g_free0 (_tmp5_.s);
		_tmp5_.s = _tmp4_;
		_tmp6_ = _tmp5_;
		_tmp7_ = _bar_dup0 (&_tmp6_);
		_tmp8_ = g_strdup ("manam");
		memset (&_tmp9_, 0, sizeof (Bar));
		_g_free0 (_tmp9_.s);
		_tmp9_.s = _tmp8_;
		_tmp10_ = _tmp9_;
		_tmp11_ = _bar_dup0 (&_tmp10_);
		_tmp12_ = g_new0 (Bar*, 3);
		_tmp12_[0] = _tmp3_;
		_tmp12_[1] = _tmp7_;
		_tmp12_[2] = _tmp11_;
		_tmp13_ = _tmp12_;
		_tmp13__length1 = 3;
		bar_destroy (&_tmp10_);
		bar_destroy (&_tmp6_);
		bar_destroy (&_tmp2_);
		bar = _tmp13_;
		bar_length1 = _tmp13__length1;
		_bar_size_ = bar_length1;
		{
			Bar b = {0};
			Bar* _tmp14_;
			Bar _tmp15_;
			Bar _tmp16_ = {0};
			Bar _tmp17_;
			const gchar* _tmp18_;
			Bar* _tmp19_;
			const gchar* _tmp20_;
			_tmp14_ = bar[0];
			_tmp15_ = *_tmp14_;
			bar_copy (&_tmp15_, &_tmp16_);
			b = _tmp16_;
			_tmp17_ = b;
			_tmp18_ = _tmp17_.s;
			_vala_assert (g_strcmp0 (_tmp18_, "foo") == 0, "b.s == \"foo\"");
			_tmp19_ = bar[0];
			_tmp20_ = (*_tmp19_).s;
			_vala_assert (g_strcmp0 (_tmp20_, "foo") == 0, "bar[0].s == \"foo\"");
			bar_destroy (&b);
		}
		{
			Bar b = {0};
			Bar* _tmp21_;
			Bar _tmp22_;
			Bar _tmp23_ = {0};
			Bar _tmp24_;
			const gchar* _tmp25_;
			Bar* _tmp26_;
			const gchar* _tmp27_;
			_tmp21_ = bar[1];
			_tmp22_ = (Bar) (*_tmp21_);
			bar_copy (&_tmp22_, &_tmp23_);
			b = _tmp23_;
			_tmp24_ = b;
			_tmp25_ = _tmp24_.s;
			_vala_assert (g_strcmp0 (_tmp25_, "bar") == 0, "b.s == \"bar\"");
			_tmp26_ = bar[1];
			_tmp27_ = (*_tmp26_).s;
			_vala_assert (g_strcmp0 (_tmp27_, "bar") == 0, "bar[1].s == \"bar\"");
			bar_destroy (&b);
		}
		{
			Bar b = {0};
			Bar* _tmp28_;
			Bar _tmp29_;
			Bar _tmp30_ = {0};
			Bar _tmp31_;
			const gchar* _tmp32_;
			Bar* _tmp33_;
			const gchar* _tmp34_;
			_tmp28_ = bar[2];
			_tmp29_ = (Bar) (*_tmp28_);
			bar_copy (&_tmp29_, &_tmp30_);
			b = _tmp30_;
			_tmp31_ = b;
			_tmp32_ = _tmp31_.s;
			_vala_assert (g_strcmp0 (_tmp32_, "manam") == 0, "b.s == \"manam\"");
			_tmp33_ = bar[2];
			_tmp34_ = (*_tmp33_).s;
			_vala_assert (g_strcmp0 (_tmp34_, "manam") == 0, "bar[2].s == \"manam\"");
			bar_destroy (&b);
		}
		bar = (_vala_array_free (bar, bar_length1, (GDestroyNotify) bar_free), NULL);
	}
	{
		Bar b = {0};
		gint _tmp35_ = 0;
		Bar** _tmp36_;
		Bar** _tmp37_;
		gint _tmp37__length1;
		Bar* _tmp38_;
		Bar _tmp39_;
		Bar _tmp40_ = {0};
		Bar _tmp41_;
		Bar _tmp42_;
		const gchar* _tmp43_;
		_tmp36_ = bar_array_owned (&_tmp35_);
		_tmp37_ = _tmp36_;
		_tmp37__length1 = _tmp35_;
		_tmp38_ = _tmp37_[0];
		_tmp39_ = *_tmp38_;
		bar_copy (&_tmp39_, &_tmp40_);
		_tmp41_ = _tmp40_;
		_tmp37_ = (_vala_array_free (_tmp37_, _tmp37__length1, (GDestroyNotify) bar_free), NULL);
		b = _tmp41_;
		_tmp42_ = b;
		_tmp43_ = _tmp42_.s;
		_vala_assert (g_strcmp0 (_tmp43_, "foo") == 0, "b.s == \"foo\"");
		bar_destroy (&b);
	}
	{
		Bar b = {0};
		gint _tmp44_ = 0;
		Bar** _tmp45_;
		Bar** _tmp46_;
		gint _tmp46__length1;
		Bar* _tmp47_;
		Bar _tmp48_;
		Bar _tmp49_ = {0};
		Bar _tmp50_;
		Bar _tmp51_;
		const gchar* _tmp52_;
		_tmp45_ = bar_array_owned (&_tmp44_);
		_tmp46_ = _tmp45_;
		_tmp46__length1 = _tmp44_;
		_tmp47_ = _tmp46_[1];
		_tmp48_ = (Bar) (*_tmp47_);
		bar_copy (&_tmp48_, &_tmp49_);
		_tmp50_ = _tmp49_;
		_tmp46_ = (_vala_array_free (_tmp46_, _tmp46__length1, (GDestroyNotify) bar_free), NULL);
		b = _tmp50_;
		_tmp51_ = b;
		_tmp52_ = _tmp51_.s;
		_vala_assert (g_strcmp0 (_tmp52_, "bar") == 0, "b.s == \"bar\"");
		bar_destroy (&b);
	}
	{
		Bar b = {0};
		gint _tmp53_ = 0;
		Bar** _tmp54_;
		Bar** _tmp55_;
		gint _tmp55__length1;
		Bar* _tmp56_;
		Bar _tmp57_;
		Bar _tmp58_ = {0};
		Bar _tmp59_;
		Bar _tmp60_;
		const gchar* _tmp61_;
		_tmp54_ = bar_array_owned (&_tmp53_);
		_tmp55_ = _tmp54_;
		_tmp55__length1 = _tmp53_;
		_tmp56_ = _tmp55_[2];
		_tmp57_ = (Bar) (*_tmp56_);
		bar_copy (&_tmp57_, &_tmp58_);
		_tmp59_ = _tmp58_;
		_tmp55_ = (_vala_array_free (_tmp55_, _tmp55__length1, (GDestroyNotify) bar_free), NULL);
		b = _tmp59_;
		_tmp60_ = b;
		_tmp61_ = _tmp60_.s;
		_vala_assert (g_strcmp0 (_tmp61_, "manam") == 0, "b.s == \"manam\"");
		bar_destroy (&b);
	}
	{
		Bar b = {0};
		gint _tmp62_ = 0;
		Bar** _tmp63_;
		Bar* _tmp64_;
		Bar _tmp65_;
		Bar _tmp66_ = {0};
		Bar _tmp67_;
		const gchar* _tmp68_;
		_tmp63_ = bar_array_unowned (&_tmp62_);
		_tmp64_ = _tmp63_[0];
		_tmp65_ = *_tmp64_;
		bar_copy (&_tmp65_, &_tmp66_);
		b = _tmp66_;
		_tmp67_ = b;
		_tmp68_ = _tmp67_.s;
		_vala_assert (g_strcmp0 (_tmp68_, "foo") == 0, "b.s == \"foo\"");
		bar_destroy (&b);
	}
	{
		Bar b = {0};
		gint _tmp69_ = 0;
		Bar** _tmp70_;
		Bar* _tmp71_;
		Bar _tmp72_;
		Bar _tmp73_ = {0};
		Bar _tmp74_;
		const gchar* _tmp75_;
		_tmp70_ = bar_array_unowned (&_tmp69_);
		_tmp71_ = _tmp70_[1];
		_tmp72_ = (Bar) (*_tmp71_);
		bar_copy (&_tmp72_, &_tmp73_);
		b = _tmp73_;
		_tmp74_ = b;
		_tmp75_ = _tmp74_.s;
		_vala_assert (g_strcmp0 (_tmp75_, "bar") == 0, "b.s == \"bar\"");
		bar_destroy (&b);
	}
	{
		Bar b = {0};
		gint _tmp76_ = 0;
		Bar** _tmp77_;
		Bar* _tmp78_;
		Bar _tmp79_;
		Bar _tmp80_ = {0};
		Bar _tmp81_;
		const gchar* _tmp82_;
		_tmp77_ = bar_array_unowned (&_tmp76_);
		_tmp78_ = _tmp77_[2];
		_tmp79_ = (Bar) (*_tmp78_);
		bar_copy (&_tmp79_, &_tmp80_);
		b = _tmp80_;
		_tmp81_ = b;
		_tmp82_ = _tmp81_.s;
		_vala_assert (g_strcmp0 (_tmp82_, "manam") == 0, "b.s == \"manam\"");
		bar_destroy (&b);
	}
}

static void
_vala_main (void)
{
	test_without_destroy ();
	test_with_destroy ();
}

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

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

