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

/* valaccodestructmodule.vala
 *
 * Copyright (C) 2006-2009  Jürg Billeter
 * Copyright (C) 2006-2008  Raffaele Sandrini
 *
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 * 	Jürg Billeter <j@bitron.ch>
 *	Raffaele Sandrini <raffaele@sandrini.ch>
 */

#include "valacodegen.h"
#include <vala.h>
#include <valaccode.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <valagee.h>
#include <glib-object.h>

#define _g_free0(var) (var = (g_free (var), NULL))
#define _vala_ccode_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_node_unref (var), NULL)))
#define _vala_typeregister_function_unref0(var) ((var == NULL) ? NULL : (var = (vala_typeregister_function_unref (var), NULL)))
#define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
#define _vala_ccode_base_module_emit_context_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_base_module_emit_context_unref (var), NULL)))
#define _vala_target_value_unref0(var) ((var == NULL) ? NULL : (var = (vala_target_value_unref (var), NULL)))

static gpointer vala_ccode_struct_module_parent_class = NULL;

static void vala_ccode_struct_module_real_generate_struct_declaration (ValaCCodeBaseModule* base,
                                                                ValaStruct* st,
                                                                ValaCCodeFile* decl_space);
static void vala_ccode_struct_module_generate_auto_cleanup_clear (ValaCCodeStructModule* self,
                                                           ValaStruct* st,
                                                           ValaCCodeFile* decl_space);
static void vala_ccode_struct_module_real_visit_struct (ValaCodeVisitor* base,
                                                 ValaStruct* st);
static void vala_ccode_struct_module_begin_struct_destroy_function (ValaCCodeStructModule* self,
                                                             ValaStruct* st);
static void vala_ccode_struct_module_add_struct_copy_function (ValaCCodeStructModule* self,
                                                        ValaStruct* st);
static void vala_ccode_struct_module_add_struct_destroy_function (ValaCCodeStructModule* self,
                                                           ValaStruct* st);
static void vala_ccode_struct_module_add_struct_dup_function (ValaCCodeStructModule* self,
                                                       ValaStruct* st);
static void vala_ccode_struct_module_add_struct_free_function (ValaCCodeStructModule* self,
                                                        ValaStruct* st);
static GType vala_ccode_struct_module_get_type_once (void);

static void
vala_ccode_struct_module_real_generate_struct_declaration (ValaCCodeBaseModule* base,
                                                           ValaStruct* st,
                                                           ValaCCodeFile* decl_space)
{
	ValaCCodeStructModule * self;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_;
	ValaStruct* _tmp3_;
	ValaStruct* _tmp4_;
	gboolean _tmp11_ = FALSE;
	gboolean _tmp12_ = FALSE;
	ValaCodeContext* _tmp36_;
	ValaCodeContext* _tmp37_;
	ValaProfile _tmp38_;
	ValaProfile _tmp39_;
	ValaStruct* _tmp58_;
	ValaStruct* _tmp59_;
	ValaCCodeStruct* instance_struct = NULL;
	gchar* _tmp80_;
	gchar* _tmp81_;
	gchar* _tmp82_;
	gchar* _tmp83_;
	ValaCCodeStruct* _tmp84_;
	ValaCCodeStruct* _tmp85_;
	ValaVersionAttribute* _tmp86_;
	ValaVersionAttribute* _tmp87_;
	gboolean _tmp88_;
	gboolean _tmp89_;
	ValaStruct* _tmp111_;
	ValaStruct* _tmp112_;
	ValaCCodeFunction* function = NULL;
	gchar* _tmp114_;
	gchar* _tmp115_;
	gchar* _tmp116_;
	gchar* _tmp117_;
	gchar* _tmp118_;
	gchar* _tmp119_;
	ValaCCodeFunction* _tmp120_;
	ValaCCodeFunction* _tmp121_;
	ValaCCodeFunction* _tmp133_;
	gchar* _tmp134_;
	gchar* _tmp135_;
	gchar* _tmp136_;
	gchar* _tmp137_;
	gchar* _tmp138_;
	gchar* _tmp139_;
	ValaCCodeParameter* _tmp140_;
	ValaCCodeParameter* _tmp141_;
	ValaCCodeFunction* _tmp142_;
	gchar* _tmp143_;
	gchar* _tmp144_;
	ValaCCodeFunction* _tmp145_;
	ValaCCodeFunction* _tmp154_;
	gchar* _tmp155_;
	gchar* _tmp156_;
	gchar* _tmp157_;
	gchar* _tmp158_;
	ValaCCodeParameter* _tmp159_;
	ValaCCodeParameter* _tmp160_;
	ValaCCodeFunction* _tmp161_;
	ValaCodeContext* _tmp209_;
	ValaCodeContext* _tmp210_;
	ValaProfile _tmp211_;
	ValaProfile _tmp212_;
	self = (ValaCCodeStructModule*) base;
	g_return_if_fail (st != NULL);
	g_return_if_fail (decl_space != NULL);
	_tmp0_ = vala_get_ccode_name ((ValaCodeNode*) st);
	_tmp1_ = _tmp0_;
	_tmp2_ = vala_ccode_base_module_add_symbol_declaration ((ValaCCodeBaseModule*) self, decl_space, (ValaSymbol*) st, _tmp1_);
	_g_free0 (_tmp1_);
	if (_tmp2_) {
		return;
	}
	_tmp3_ = vala_struct_get_base_struct (st);
	_tmp4_ = _tmp3_;
	if (_tmp4_ != NULL) {
		ValaStruct* _tmp5_;
		ValaStruct* _tmp6_;
		_tmp5_ = vala_struct_get_base_struct (st);
		_tmp6_ = _tmp5_;
		vala_ccode_base_module_generate_struct_declaration ((ValaCCodeBaseModule*) self, _tmp6_, decl_space);
	} else {
		gboolean _tmp7_;
		gboolean _tmp8_;
		_tmp7_ = vala_symbol_get_external_package ((ValaSymbol*) st);
		_tmp8_ = _tmp7_;
		if (!_tmp8_) {
			gboolean _tmp9_ = FALSE;
			ValaAttribute* _tmp10_;
			_tmp10_ = vala_code_node_get_attribute ((ValaCodeNode*) st, "SimpleType");
			if (_tmp10_ != NULL) {
				_tmp9_ = !vala_code_node_has_attribute_argument ((ValaCodeNode*) st, "CCode", "type_id");
			} else {
				_tmp9_ = FALSE;
			}
			if (_tmp9_) {
				vala_code_node_set_attribute_bool ((ValaCodeNode*) st, "CCode", "has_type_id", FALSE, NULL);
			}
		}
	}
	if (vala_struct_is_boolean_type (st)) {
		_tmp12_ = TRUE;
	} else {
		_tmp12_ = vala_struct_is_integer_type (st);
	}
	if (_tmp12_) {
		_tmp11_ = TRUE;
	} else {
		_tmp11_ = vala_struct_is_floating_type (st);
	}
	if (_tmp11_) {
		gchar* typename = NULL;
		ValaStruct* _tmp13_;
		ValaStruct* _tmp14_;
		const gchar* _tmp29_;
		gchar* _tmp30_;
		gchar* _tmp31_;
		ValaCCodeVariableDeclarator* _tmp32_;
		ValaCCodeVariableDeclarator* _tmp33_;
		ValaCCodeTypeDefinition* _tmp34_;
		ValaCCodeTypeDefinition* _tmp35_;
		_tmp13_ = vala_struct_get_base_struct (st);
		_tmp14_ = _tmp13_;
		if (_tmp14_ != NULL) {
			ValaStruct* _tmp15_;
			ValaStruct* _tmp16_;
			gchar* _tmp17_;
			_tmp15_ = vala_struct_get_base_struct (st);
			_tmp16_ = _tmp15_;
			_tmp17_ = vala_get_ccode_name ((ValaCodeNode*) _tmp16_);
			_g_free0 (typename);
			typename = _tmp17_;
		} else {
			if (vala_struct_is_boolean_type (st)) {
				gchar* _tmp18_;
				vala_ccode_file_add_include (decl_space, "stdbool.h", FALSE);
				_tmp18_ = g_strdup ("bool");
				_g_free0 (typename);
				typename = _tmp18_;
			} else {
				if (vala_struct_is_integer_type (st)) {
					const gchar* _tmp19_ = NULL;
					gboolean _tmp20_;
					gboolean _tmp21_;
					gint _tmp22_;
					gint _tmp23_;
					gchar* _tmp24_;
					vala_ccode_file_add_include (decl_space, "stdint.h", FALSE);
					_tmp20_ = vala_struct_get_signed (st);
					_tmp21_ = _tmp20_;
					if (_tmp21_) {
						_tmp19_ = "";
					} else {
						_tmp19_ = "u";
					}
					_tmp22_ = vala_struct_get_width (st);
					_tmp23_ = _tmp22_;
					_tmp24_ = g_strdup_printf ("%sint%d_t", _tmp19_, _tmp23_);
					_g_free0 (typename);
					typename = _tmp24_;
				} else {
					if (vala_struct_is_floating_type (st)) {
						const gchar* _tmp25_ = NULL;
						gint _tmp26_;
						gint _tmp27_;
						gchar* _tmp28_;
						_tmp26_ = vala_struct_get_width (st);
						_tmp27_ = _tmp26_;
						if (_tmp27_ == 64) {
							_tmp25_ = "double";
						} else {
							_tmp25_ = "float";
						}
						_tmp28_ = g_strdup (_tmp25_);
						_g_free0 (typename);
						typename = _tmp28_;
					} else {
						g_assert_not_reached ();
					}
				}
			}
		}
		_tmp29_ = typename;
		_tmp30_ = vala_get_ccode_name ((ValaCodeNode*) st);
		_tmp31_ = _tmp30_;
		_tmp32_ = vala_ccode_variable_declarator_new (_tmp31_, NULL, NULL);
		_tmp33_ = _tmp32_;
		_tmp34_ = vala_ccode_type_definition_new (_tmp29_, (ValaCCodeDeclarator*) _tmp33_);
		_tmp35_ = _tmp34_;
		vala_ccode_file_add_type_declaration (decl_space, (ValaCCodeNode*) _tmp35_);
		_vala_ccode_node_unref0 (_tmp35_);
		_vala_ccode_node_unref0 (_tmp33_);
		_g_free0 (_tmp31_);
		_g_free0 (typename);
		return;
	}
	_tmp36_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
	_tmp37_ = _tmp36_;
	_tmp38_ = vala_code_context_get_profile (_tmp37_);
	_tmp39_ = _tmp38_;
	if (_tmp39_ == VALA_PROFILE_GOBJECT) {
		if (vala_get_ccode_has_type_id ((ValaTypeSymbol*) st)) {
			ValaCCodeNewline* _tmp40_;
			ValaCCodeNewline* _tmp41_;
			gchar* macro = NULL;
			gchar* _tmp42_;
			gchar* _tmp43_;
			gchar* _tmp44_;
			gchar* _tmp45_;
			gchar* _tmp46_;
			gchar* _tmp47_;
			const gchar* _tmp48_;
			ValaCCodeMacroReplacement* _tmp49_;
			ValaCCodeMacroReplacement* _tmp50_;
			ValaStructRegisterFunction* type_fun = NULL;
			ValaStructRegisterFunction* _tmp51_;
			ValaStructRegisterFunction* _tmp52_;
			ValaCodeContext* _tmp53_;
			ValaCodeContext* _tmp54_;
			ValaStructRegisterFunction* _tmp55_;
			ValaCCodeFragment* _tmp56_;
			ValaCCodeFragment* _tmp57_;
			vala_ccode_file_add_include (decl_space, "glib-object.h", FALSE);
			_tmp40_ = vala_ccode_newline_new ();
			_tmp41_ = _tmp40_;
			vala_ccode_file_add_type_declaration (decl_space, (ValaCCodeNode*) _tmp41_);
			_vala_ccode_node_unref0 (_tmp41_);
			_tmp42_ = vala_get_ccode_lower_case_name ((ValaCodeNode*) st, NULL);
			_tmp43_ = _tmp42_;
			_tmp44_ = g_strdup_printf ("(%s_get_type ())", _tmp43_);
			_tmp45_ = _tmp44_;
			_g_free0 (_tmp43_);
			macro = _tmp45_;
			_tmp46_ = vala_get_ccode_type_id ((ValaCodeNode*) st);
			_tmp47_ = _tmp46_;
			_tmp48_ = macro;
			_tmp49_ = vala_ccode_macro_replacement_new (_tmp47_, _tmp48_);
			_tmp50_ = _tmp49_;
			vala_ccode_file_add_type_declaration (decl_space, (ValaCCodeNode*) _tmp50_);
			_vala_ccode_node_unref0 (_tmp50_);
			_g_free0 (_tmp47_);
			_tmp51_ = vala_struct_register_function_new (st);
			type_fun = _tmp51_;
			_tmp52_ = type_fun;
			_tmp53_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
			_tmp54_ = _tmp53_;
			vala_typeregister_function_init_from_type ((ValaTypeRegisterFunction*) _tmp52_, _tmp54_, FALSE, TRUE);
			_tmp55_ = type_fun;
			_tmp56_ = vala_typeregister_function_get_declaration ((ValaTypeRegisterFunction*) _tmp55_);
			_tmp57_ = _tmp56_;
			vala_ccode_file_add_type_member_declaration (decl_space, (ValaCCodeNode*) _tmp57_);
			_vala_ccode_node_unref0 (_tmp57_);
			((ValaCCodeBaseModule*) self)->requires_vala_extern = TRUE;
			_vala_typeregister_function_unref0 (type_fun);
			_g_free0 (macro);
		}
	}
	_tmp58_ = vala_struct_get_base_struct (st);
	_tmp59_ = _tmp58_;
	if (_tmp59_ == NULL) {
		gchar* _tmp60_;
		gchar* _tmp61_;
		gchar* _tmp62_;
		gchar* _tmp63_;
		gchar* _tmp64_;
		gchar* _tmp65_;
		ValaCCodeVariableDeclarator* _tmp66_;
		ValaCCodeVariableDeclarator* _tmp67_;
		ValaCCodeTypeDefinition* _tmp68_;
		ValaCCodeTypeDefinition* _tmp69_;
		_tmp60_ = vala_get_ccode_name ((ValaCodeNode*) st);
		_tmp61_ = _tmp60_;
		_tmp62_ = g_strdup_printf ("struct _%s", _tmp61_);
		_tmp63_ = _tmp62_;
		_tmp64_ = vala_get_ccode_name ((ValaCodeNode*) st);
		_tmp65_ = _tmp64_;
		_tmp66_ = vala_ccode_variable_declarator_new (_tmp65_, NULL, NULL);
		_tmp67_ = _tmp66_;
		_tmp68_ = vala_ccode_type_definition_new (_tmp63_, (ValaCCodeDeclarator*) _tmp67_);
		_tmp69_ = _tmp68_;
		vala_ccode_file_add_type_declaration (decl_space, (ValaCCodeNode*) _tmp69_);
		_vala_ccode_node_unref0 (_tmp69_);
		_vala_ccode_node_unref0 (_tmp67_);
		_g_free0 (_tmp65_);
		_g_free0 (_tmp63_);
		_g_free0 (_tmp61_);
	} else {
		ValaStruct* _tmp70_;
		ValaStruct* _tmp71_;
		gchar* _tmp72_;
		gchar* _tmp73_;
		gchar* _tmp74_;
		gchar* _tmp75_;
		ValaCCodeVariableDeclarator* _tmp76_;
		ValaCCodeVariableDeclarator* _tmp77_;
		ValaCCodeTypeDefinition* _tmp78_;
		ValaCCodeTypeDefinition* _tmp79_;
		_tmp70_ = vala_struct_get_base_struct (st);
		_tmp71_ = _tmp70_;
		_tmp72_ = vala_get_ccode_name ((ValaCodeNode*) _tmp71_);
		_tmp73_ = _tmp72_;
		_tmp74_ = vala_get_ccode_name ((ValaCodeNode*) st);
		_tmp75_ = _tmp74_;
		_tmp76_ = vala_ccode_variable_declarator_new (_tmp75_, NULL, NULL);
		_tmp77_ = _tmp76_;
		_tmp78_ = vala_ccode_type_definition_new (_tmp73_, (ValaCCodeDeclarator*) _tmp77_);
		_tmp79_ = _tmp78_;
		vala_ccode_file_add_type_declaration (decl_space, (ValaCCodeNode*) _tmp79_);
		_vala_ccode_node_unref0 (_tmp79_);
		_vala_ccode_node_unref0 (_tmp77_);
		_g_free0 (_tmp75_);
		_g_free0 (_tmp73_);
	}
	_tmp80_ = vala_get_ccode_name ((ValaCodeNode*) st);
	_tmp81_ = _tmp80_;
	_tmp82_ = g_strdup_printf ("_%s", _tmp81_);
	_tmp83_ = _tmp82_;
	_tmp84_ = vala_ccode_struct_new (_tmp83_);
	_tmp85_ = _tmp84_;
	_g_free0 (_tmp83_);
	_g_free0 (_tmp81_);
	instance_struct = _tmp85_;
	_tmp86_ = vala_symbol_get_version ((ValaSymbol*) st);
	_tmp87_ = _tmp86_;
	_tmp88_ = vala_version_attribute_get_deprecated (_tmp87_);
	_tmp89_ = _tmp88_;
	if (_tmp89_) {
		ValaCodeContext* _tmp90_;
		ValaCodeContext* _tmp91_;
		ValaProfile _tmp92_;
		ValaProfile _tmp93_;
		ValaCCodeStruct* _tmp94_;
		ValaCCodeStruct* _tmp95_;
		ValaCCodeModifiers _tmp96_;
		ValaCCodeModifiers _tmp97_;
		_tmp90_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
		_tmp91_ = _tmp90_;
		_tmp92_ = vala_code_context_get_profile (_tmp91_);
		_tmp93_ = _tmp92_;
		if (_tmp93_ == VALA_PROFILE_GOBJECT) {
			vala_ccode_file_add_include (decl_space, "glib.h", FALSE);
		}
		_tmp94_ = instance_struct;
		_tmp95_ = instance_struct;
		_tmp96_ = vala_ccode_node_get_modifiers ((ValaCCodeNode*) _tmp95_);
		_tmp97_ = _tmp96_;
		vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp95_, _tmp97_ | VALA_CCODE_MODIFIERS_DEPRECATED);
	}
	{
		ValaList* _f_list = NULL;
		ValaList* _tmp98_;
		gint _f_size = 0;
		ValaList* _tmp99_;
		gint _tmp100_;
		gint _tmp101_;
		gint _f_index = 0;
		_tmp98_ = vala_struct_get_fields (st);
		_f_list = _tmp98_;
		_tmp99_ = _f_list;
		_tmp100_ = vala_collection_get_size ((ValaCollection*) _tmp99_);
		_tmp101_ = _tmp100_;
		_f_size = _tmp101_;
		_f_index = -1;
		while (TRUE) {
			gint _tmp102_;
			gint _tmp103_;
			ValaField* f = NULL;
			ValaList* _tmp104_;
			gpointer _tmp105_;
			ValaField* _tmp106_;
			ValaMemberBinding _tmp107_;
			ValaMemberBinding _tmp108_;
			_f_index = _f_index + 1;
			_tmp102_ = _f_index;
			_tmp103_ = _f_size;
			if (!(_tmp102_ < _tmp103_)) {
				break;
			}
			_tmp104_ = _f_list;
			_tmp105_ = vala_list_get (_tmp104_, _f_index);
			f = (ValaField*) _tmp105_;
			_tmp106_ = f;
			_tmp107_ = vala_field_get_binding (_tmp106_);
			_tmp108_ = _tmp107_;
			if (_tmp108_ == VALA_MEMBER_BINDING_INSTANCE) {
				ValaCCodeStruct* _tmp109_;
				ValaField* _tmp110_;
				_tmp109_ = instance_struct;
				_tmp110_ = f;
				vala_ccode_base_module_append_field ((ValaCCodeBaseModule*) self, _tmp109_, _tmp110_, decl_space);
			}
			_vala_code_node_unref0 (f);
		}
	}
	_tmp111_ = vala_struct_get_base_struct (st);
	_tmp112_ = _tmp111_;
	if (_tmp112_ == NULL) {
		ValaCCodeStruct* _tmp113_;
		_tmp113_ = instance_struct;
		vala_ccode_file_add_type_definition (decl_space, (ValaCCodeNode*) _tmp113_);
	}
	if (vala_struct_is_simple_type (st)) {
		_vala_ccode_node_unref0 (instance_struct);
		return;
	}
	_tmp114_ = vala_get_ccode_dup_function ((ValaTypeSymbol*) st);
	_tmp115_ = _tmp114_;
	_tmp116_ = vala_get_ccode_name ((ValaCodeNode*) st);
	_tmp117_ = _tmp116_;
	_tmp118_ = g_strconcat (_tmp117_, "*", NULL);
	_tmp119_ = _tmp118_;
	_tmp120_ = vala_ccode_function_new (_tmp115_, _tmp119_);
	_tmp121_ = _tmp120_;
	_g_free0 (_tmp119_);
	_g_free0 (_tmp117_);
	_g_free0 (_tmp115_);
	function = _tmp121_;
	if (vala_symbol_is_private_symbol ((ValaSymbol*) st)) {
		ValaCCodeFunction* _tmp122_;
		_tmp122_ = function;
		vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp122_, VALA_CCODE_MODIFIERS_STATIC);
	} else {
		gboolean _tmp123_ = FALSE;
		ValaCodeContext* _tmp124_;
		ValaCodeContext* _tmp125_;
		gboolean _tmp126_;
		gboolean _tmp127_;
		_tmp124_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
		_tmp125_ = _tmp124_;
		_tmp126_ = vala_code_context_get_hide_internal (_tmp125_);
		_tmp127_ = _tmp126_;
		if (_tmp127_) {
			_tmp123_ = vala_symbol_is_internal_symbol ((ValaSymbol*) st);
		} else {
			_tmp123_ = FALSE;
		}
		if (_tmp123_) {
			ValaCCodeFunction* _tmp128_;
			_tmp128_ = function;
			vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp128_, VALA_CCODE_MODIFIERS_INTERNAL);
		} else {
			ValaCCodeFunction* _tmp129_;
			ValaCCodeFunction* _tmp130_;
			ValaCCodeModifiers _tmp131_;
			ValaCCodeModifiers _tmp132_;
			_tmp129_ = function;
			_tmp130_ = function;
			_tmp131_ = vala_ccode_node_get_modifiers ((ValaCCodeNode*) _tmp130_);
			_tmp132_ = _tmp131_;
			vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp130_, _tmp132_ | VALA_CCODE_MODIFIERS_EXTERN);
			((ValaCCodeBaseModule*) self)->requires_vala_extern = TRUE;
		}
	}
	_tmp133_ = function;
	_tmp134_ = vala_get_ccode_name ((ValaCodeNode*) st);
	_tmp135_ = _tmp134_;
	_tmp136_ = g_strconcat ("const ", _tmp135_, NULL);
	_tmp137_ = _tmp136_;
	_tmp138_ = g_strconcat (_tmp137_, "*", NULL);
	_tmp139_ = _tmp138_;
	_tmp140_ = vala_ccode_parameter_new ("self", _tmp139_);
	_tmp141_ = _tmp140_;
	vala_ccode_function_add_parameter (_tmp133_, _tmp141_);
	_vala_ccode_node_unref0 (_tmp141_);
	_g_free0 (_tmp139_);
	_g_free0 (_tmp137_);
	_g_free0 (_tmp135_);
	_tmp142_ = function;
	vala_ccode_file_add_function_declaration (decl_space, _tmp142_);
	_tmp143_ = vala_get_ccode_free_function ((ValaTypeSymbol*) st);
	_tmp144_ = _tmp143_;
	_tmp145_ = vala_ccode_function_new (_tmp144_, "void");
	_vala_ccode_node_unref0 (function);
	function = _tmp145_;
	_g_free0 (_tmp144_);
	if (vala_symbol_is_private_symbol ((ValaSymbol*) st)) {
		ValaCCodeFunction* _tmp146_;
		_tmp146_ = function;
		vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp146_, VALA_CCODE_MODIFIERS_STATIC);
	} else {
		gboolean _tmp147_ = FALSE;
		ValaCodeContext* _tmp148_;
		ValaCodeContext* _tmp149_;
		gboolean _tmp150_;
		gboolean _tmp151_;
		_tmp148_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
		_tmp149_ = _tmp148_;
		_tmp150_ = vala_code_context_get_hide_internal (_tmp149_);
		_tmp151_ = _tmp150_;
		if (_tmp151_) {
			_tmp147_ = vala_symbol_is_internal_symbol ((ValaSymbol*) st);
		} else {
			_tmp147_ = FALSE;
		}
		if (_tmp147_) {
			ValaCCodeFunction* _tmp152_;
			_tmp152_ = function;
			vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp152_, VALA_CCODE_MODIFIERS_INTERNAL);
		} else {
			ValaCCodeFunction* _tmp153_;
			_tmp153_ = function;
			vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp153_, VALA_CCODE_MODIFIERS_EXTERN);
			((ValaCCodeBaseModule*) self)->requires_vala_extern = TRUE;
		}
	}
	_tmp154_ = function;
	_tmp155_ = vala_get_ccode_name ((ValaCodeNode*) st);
	_tmp156_ = _tmp155_;
	_tmp157_ = g_strconcat (_tmp156_, "*", NULL);
	_tmp158_ = _tmp157_;
	_tmp159_ = vala_ccode_parameter_new ("self", _tmp158_);
	_tmp160_ = _tmp159_;
	vala_ccode_function_add_parameter (_tmp154_, _tmp160_);
	_vala_ccode_node_unref0 (_tmp160_);
	_g_free0 (_tmp158_);
	_g_free0 (_tmp156_);
	_tmp161_ = function;
	vala_ccode_file_add_function_declaration (decl_space, _tmp161_);
	if (vala_struct_is_disposable (st)) {
		gchar* _tmp162_;
		gchar* _tmp163_;
		ValaCCodeFunction* _tmp164_;
		ValaCCodeFunction* _tmp173_;
		gchar* _tmp174_;
		gchar* _tmp175_;
		gchar* _tmp176_;
		gchar* _tmp177_;
		gchar* _tmp178_;
		gchar* _tmp179_;
		ValaCCodeParameter* _tmp180_;
		ValaCCodeParameter* _tmp181_;
		ValaCCodeFunction* _tmp182_;
		gchar* _tmp183_;
		gchar* _tmp184_;
		gchar* _tmp185_;
		gchar* _tmp186_;
		ValaCCodeParameter* _tmp187_;
		ValaCCodeParameter* _tmp188_;
		ValaCCodeFunction* _tmp189_;
		gchar* _tmp190_;
		gchar* _tmp191_;
		ValaCCodeFunction* _tmp192_;
		ValaCCodeFunction* _tmp201_;
		gchar* _tmp202_;
		gchar* _tmp203_;
		gchar* _tmp204_;
		gchar* _tmp205_;
		ValaCCodeParameter* _tmp206_;
		ValaCCodeParameter* _tmp207_;
		ValaCCodeFunction* _tmp208_;
		_tmp162_ = vala_get_ccode_copy_function ((ValaTypeSymbol*) st);
		_tmp163_ = _tmp162_;
		_tmp164_ = vala_ccode_function_new (_tmp163_, "void");
		_vala_ccode_node_unref0 (function);
		function = _tmp164_;
		_g_free0 (_tmp163_);
		if (vala_symbol_is_private_symbol ((ValaSymbol*) st)) {
			ValaCCodeFunction* _tmp165_;
			_tmp165_ = function;
			vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp165_, VALA_CCODE_MODIFIERS_STATIC);
		} else {
			gboolean _tmp166_ = FALSE;
			ValaCodeContext* _tmp167_;
			ValaCodeContext* _tmp168_;
			gboolean _tmp169_;
			gboolean _tmp170_;
			_tmp167_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
			_tmp168_ = _tmp167_;
			_tmp169_ = vala_code_context_get_hide_internal (_tmp168_);
			_tmp170_ = _tmp169_;
			if (_tmp170_) {
				_tmp166_ = vala_symbol_is_internal_symbol ((ValaSymbol*) st);
			} else {
				_tmp166_ = FALSE;
			}
			if (_tmp166_) {
				ValaCCodeFunction* _tmp171_;
				_tmp171_ = function;
				vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp171_, VALA_CCODE_MODIFIERS_INTERNAL);
			} else {
				ValaCCodeFunction* _tmp172_;
				_tmp172_ = function;
				vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp172_, VALA_CCODE_MODIFIERS_EXTERN);
				((ValaCCodeBaseModule*) self)->requires_vala_extern = TRUE;
			}
		}
		_tmp173_ = function;
		_tmp174_ = vala_get_ccode_name ((ValaCodeNode*) st);
		_tmp175_ = _tmp174_;
		_tmp176_ = g_strconcat ("const ", _tmp175_, NULL);
		_tmp177_ = _tmp176_;
		_tmp178_ = g_strconcat (_tmp177_, "*", NULL);
		_tmp179_ = _tmp178_;
		_tmp180_ = vala_ccode_parameter_new ("self", _tmp179_);
		_tmp181_ = _tmp180_;
		vala_ccode_function_add_parameter (_tmp173_, _tmp181_);
		_vala_ccode_node_unref0 (_tmp181_);
		_g_free0 (_tmp179_);
		_g_free0 (_tmp177_);
		_g_free0 (_tmp175_);
		_tmp182_ = function;
		_tmp183_ = vala_get_ccode_name ((ValaCodeNode*) st);
		_tmp184_ = _tmp183_;
		_tmp185_ = g_strconcat (_tmp184_, "*", NULL);
		_tmp186_ = _tmp185_;
		_tmp187_ = vala_ccode_parameter_new ("dest", _tmp186_);
		_tmp188_ = _tmp187_;
		vala_ccode_function_add_parameter (_tmp182_, _tmp188_);
		_vala_ccode_node_unref0 (_tmp188_);
		_g_free0 (_tmp186_);
		_g_free0 (_tmp184_);
		_tmp189_ = function;
		vala_ccode_file_add_function_declaration (decl_space, _tmp189_);
		_tmp190_ = vala_get_ccode_destroy_function ((ValaTypeSymbol*) st);
		_tmp191_ = _tmp190_;
		_tmp192_ = vala_ccode_function_new (_tmp191_, "void");
		_vala_ccode_node_unref0 (function);
		function = _tmp192_;
		_g_free0 (_tmp191_);
		if (vala_symbol_is_private_symbol ((ValaSymbol*) st)) {
			ValaCCodeFunction* _tmp193_;
			_tmp193_ = function;
			vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp193_, VALA_CCODE_MODIFIERS_STATIC);
		} else {
			gboolean _tmp194_ = FALSE;
			ValaCodeContext* _tmp195_;
			ValaCodeContext* _tmp196_;
			gboolean _tmp197_;
			gboolean _tmp198_;
			_tmp195_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
			_tmp196_ = _tmp195_;
			_tmp197_ = vala_code_context_get_hide_internal (_tmp196_);
			_tmp198_ = _tmp197_;
			if (_tmp198_) {
				_tmp194_ = vala_symbol_is_internal_symbol ((ValaSymbol*) st);
			} else {
				_tmp194_ = FALSE;
			}
			if (_tmp194_) {
				ValaCCodeFunction* _tmp199_;
				_tmp199_ = function;
				vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp199_, VALA_CCODE_MODIFIERS_INTERNAL);
			} else {
				ValaCCodeFunction* _tmp200_;
				_tmp200_ = function;
				vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp200_, VALA_CCODE_MODIFIERS_EXTERN);
				((ValaCCodeBaseModule*) self)->requires_vala_extern = TRUE;
			}
		}
		_tmp201_ = function;
		_tmp202_ = vala_get_ccode_name ((ValaCodeNode*) st);
		_tmp203_ = _tmp202_;
		_tmp204_ = g_strconcat (_tmp203_, "*", NULL);
		_tmp205_ = _tmp204_;
		_tmp206_ = vala_ccode_parameter_new ("self", _tmp205_);
		_tmp207_ = _tmp206_;
		vala_ccode_function_add_parameter (_tmp201_, _tmp207_);
		_vala_ccode_node_unref0 (_tmp207_);
		_g_free0 (_tmp205_);
		_g_free0 (_tmp203_);
		_tmp208_ = function;
		vala_ccode_file_add_function_declaration (decl_space, _tmp208_);
	}
	_tmp209_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
	_tmp210_ = _tmp209_;
	_tmp211_ = vala_code_context_get_profile (_tmp210_);
	_tmp212_ = _tmp211_;
	if (_tmp212_ == VALA_PROFILE_GOBJECT) {
		vala_ccode_struct_module_generate_auto_cleanup_clear (self, st, decl_space);
	}
	_vala_ccode_node_unref0 (function);
	_vala_ccode_node_unref0 (instance_struct);
}

static void
vala_ccode_struct_module_generate_auto_cleanup_clear (ValaCCodeStructModule* self,
                                                      ValaStruct* st,
                                                      ValaCCodeFile* decl_space)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (st != NULL);
	g_return_if_fail (decl_space != NULL);
	if (vala_struct_is_disposable (st)) {
		gboolean _tmp1_ = FALSE;
		gboolean _tmp2_ = FALSE;
		ValaCodeContext* _tmp3_;
		ValaCodeContext* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		_tmp3_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
		_tmp4_ = _tmp3_;
		_tmp5_ = vala_code_context_get_header_filename (_tmp4_);
		_tmp6_ = _tmp5_;
		if (_tmp6_ == NULL) {
			_tmp2_ = TRUE;
		} else {
			CCodeFileType _tmp7_;
			CCodeFileType _tmp8_;
			_tmp7_ = vala_ccode_file_get_file_type (decl_space);
			_tmp8_ = _tmp7_;
			_tmp2_ = _tmp8_ == CCODE_FILE_TYPE_PUBLIC_HEADER;
		}
		if (_tmp2_) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp9_ = FALSE;
			CCodeFileType _tmp10_;
			CCodeFileType _tmp11_;
			_tmp10_ = vala_ccode_file_get_file_type (decl_space);
			_tmp11_ = _tmp10_;
			if (_tmp11_ == CCODE_FILE_TYPE_INTERNAL_HEADER) {
				_tmp9_ = vala_symbol_is_internal_symbol ((ValaSymbol*) st);
			} else {
				_tmp9_ = FALSE;
			}
			_tmp1_ = _tmp9_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gchar* auto_cleanup_clear_func = NULL;
		gchar* _tmp12_;
		gboolean _tmp13_ = FALSE;
		const gchar* _tmp14_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		const gchar* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		ValaCCodeIdentifier* _tmp23_;
		ValaCCodeIdentifier* _tmp24_;
		ValaCCodeNewline* _tmp25_;
		ValaCCodeNewline* _tmp26_;
		_tmp12_ = vala_get_ccode_destroy_function ((ValaTypeSymbol*) st);
		auto_cleanup_clear_func = _tmp12_;
		_tmp14_ = auto_cleanup_clear_func;
		if (_tmp14_ == NULL) {
			_tmp13_ = TRUE;
		} else {
			const gchar* _tmp15_;
			_tmp15_ = auto_cleanup_clear_func;
			_tmp13_ = g_strcmp0 (_tmp15_, "") == 0;
		}
		if (_tmp13_) {
			ValaSourceReference* _tmp16_;
			ValaSourceReference* _tmp17_;
			_tmp16_ = vala_code_node_get_source_reference ((ValaCodeNode*) st);
			_tmp17_ = _tmp16_;
			vala_report_error (_tmp17_, "internal error: auto_cleanup_clear_func not available");
		}
		_tmp18_ = vala_get_ccode_name ((ValaCodeNode*) st);
		_tmp19_ = _tmp18_;
		_tmp20_ = auto_cleanup_clear_func;
		_tmp21_ = g_strdup_printf ("G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (%s, %s)", _tmp19_, _tmp20_);
		_tmp22_ = _tmp21_;
		_tmp23_ = vala_ccode_identifier_new (_tmp22_);
		_tmp24_ = _tmp23_;
		vala_ccode_file_add_type_member_declaration (decl_space, (ValaCCodeNode*) _tmp24_);
		_vala_ccode_node_unref0 (_tmp24_);
		_g_free0 (_tmp22_);
		_g_free0 (_tmp19_);
		_tmp25_ = vala_ccode_newline_new ();
		_tmp26_ = _tmp25_;
		vala_ccode_file_add_type_member_declaration (decl_space, (ValaCCodeNode*) _tmp26_);
		_vala_ccode_node_unref0 (_tmp26_);
		_g_free0 (auto_cleanup_clear_func);
	}
}

static gpointer
_vala_ccode_base_module_emit_context_ref0 (gpointer self)
{
	return self ? vala_ccode_base_module_emit_context_ref (self) : NULL;
}

static void
vala_ccode_struct_module_real_visit_struct (ValaCodeVisitor* base,
                                            ValaStruct* st)
{
	ValaCCodeStructModule * self;
	ValaCCodeBaseModuleEmitContext* _tmp0_;
	ValaCCodeBaseModuleEmitContext* _tmp1_;
	ValaSourceReference* _tmp2_;
	ValaSourceReference* _tmp3_;
	ValaCCodeBaseModuleEmitContext* old_instance_finalize_context = NULL;
	ValaCCodeBaseModuleEmitContext* _tmp4_;
	ValaCCodeBaseModuleEmitContext* _tmp5_;
	ValaCCodeBaseModuleEmitContext* _tmp6_;
	ValaCCodeFile* _tmp7_;
	gboolean _tmp10_ = FALSE;
	gboolean _tmp11_ = FALSE;
	gboolean _tmp12_ = FALSE;
	gboolean _tmp13_ = FALSE;
	ValaCCodeBaseModuleEmitContext* _tmp14_;
	ValaCCodeBaseModuleEmitContext* _tmp15_;
	self = (ValaCCodeStructModule*) base;
	g_return_if_fail (st != NULL);
	_tmp0_ = vala_ccode_base_module_emit_context_new ((ValaSymbol*) st);
	_tmp1_ = _tmp0_;
	vala_ccode_base_module_push_context ((ValaCCodeBaseModule*) self, _tmp1_);
	_vala_ccode_base_module_emit_context_unref0 (_tmp1_);
	_tmp2_ = vala_code_node_get_source_reference ((ValaCodeNode*) st);
	_tmp3_ = _tmp2_;
	vala_ccode_base_module_push_line ((ValaCCodeBaseModule*) self, _tmp3_);
	_tmp4_ = ((ValaCCodeBaseModule*) self)->instance_finalize_context;
	_tmp5_ = _vala_ccode_base_module_emit_context_ref0 (_tmp4_);
	old_instance_finalize_context = _tmp5_;
	_tmp6_ = vala_ccode_base_module_emit_context_new (NULL);
	_vala_ccode_base_module_emit_context_unref0 (((ValaCCodeBaseModule*) self)->instance_finalize_context);
	((ValaCCodeBaseModule*) self)->instance_finalize_context = _tmp6_;
	_tmp7_ = ((ValaCCodeBaseModule*) self)->cfile;
	vala_ccode_base_module_generate_struct_declaration ((ValaCCodeBaseModule*) self, st, _tmp7_);
	if (!vala_symbol_is_internal_symbol ((ValaSymbol*) st)) {
		ValaCCodeFile* _tmp8_;
		_tmp8_ = ((ValaCCodeBaseModule*) self)->header_file;
		vala_ccode_base_module_generate_struct_declaration ((ValaCCodeBaseModule*) self, st, _tmp8_);
	}
	if (!vala_symbol_is_private_symbol ((ValaSymbol*) st)) {
		ValaCCodeFile* _tmp9_;
		_tmp9_ = ((ValaCCodeBaseModule*) self)->internal_header_file;
		vala_ccode_base_module_generate_struct_declaration ((ValaCCodeBaseModule*) self, st, _tmp9_);
	}
	if (!vala_struct_is_boolean_type (st)) {
		_tmp11_ = !vala_struct_is_integer_type (st);
	} else {
		_tmp11_ = FALSE;
	}
	if (_tmp11_) {
		_tmp10_ = !vala_struct_is_floating_type (st);
	} else {
		_tmp10_ = FALSE;
	}
	if (_tmp10_) {
		if (vala_struct_is_disposable (st)) {
			vala_ccode_struct_module_begin_struct_destroy_function (self, st);
		}
	}
	vala_code_node_accept_children ((ValaCodeNode*) st, (ValaCodeVisitor*) self);
	if (!vala_struct_is_boolean_type (st)) {
		_tmp13_ = !vala_struct_is_integer_type (st);
	} else {
		_tmp13_ = FALSE;
	}
	if (_tmp13_) {
		_tmp12_ = !vala_struct_is_floating_type (st);
	} else {
		_tmp12_ = FALSE;
	}
	if (_tmp12_) {
		if (vala_struct_is_disposable (st)) {
			vala_ccode_struct_module_add_struct_copy_function (self, st);
			vala_ccode_struct_module_add_struct_destroy_function (self, st);
		}
		if (!vala_struct_is_simple_type (st)) {
			vala_ccode_struct_module_add_struct_dup_function (self, st);
			vala_ccode_struct_module_add_struct_free_function (self, st);
		}
	}
	_tmp14_ = old_instance_finalize_context;
	_tmp15_ = _vala_ccode_base_module_emit_context_ref0 (_tmp14_);
	_vala_ccode_base_module_emit_context_unref0 (((ValaCCodeBaseModule*) self)->instance_finalize_context);
	((ValaCCodeBaseModule*) self)->instance_finalize_context = _tmp15_;
	vala_ccode_base_module_pop_line ((ValaCCodeBaseModule*) self);
	vala_ccode_base_module_pop_context ((ValaCCodeBaseModule*) self);
	_vala_ccode_base_module_emit_context_unref0 (old_instance_finalize_context);
}

static void
vala_ccode_struct_module_add_struct_dup_function (ValaCCodeStructModule* self,
                                                  ValaStruct* st)
{
	ValaCCodeFunction* function = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	ValaCCodeFunction* _tmp6_;
	ValaCCodeFunction* _tmp7_;
	ValaSymbolAccessibility _tmp8_;
	ValaSymbolAccessibility _tmp9_;
	ValaCCodeFunction* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	ValaCCodeParameter* _tmp18_;
	ValaCCodeParameter* _tmp19_;
	ValaCCodeFunction* _tmp20_;
	ValaCCodeFunction* _tmp21_;
	ValaCCodeFunction* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	ValaCCodeVariableDeclarator* _tmp27_;
	ValaCCodeVariableDeclarator* _tmp28_;
	ValaCodeContext* _tmp29_;
	ValaCodeContext* _tmp30_;
	ValaProfile _tmp31_;
	ValaProfile _tmp32_;
	ValaCCodeFunction* _tmp119_;
	ValaCCodeFunction* _tmp120_;
	ValaCCodeIdentifier* _tmp121_;
	ValaCCodeIdentifier* _tmp122_;
	ValaCCodeFile* _tmp123_;
	ValaCCodeFunction* _tmp124_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (st != NULL);
	_tmp0_ = vala_get_ccode_dup_function ((ValaTypeSymbol*) st);
	_tmp1_ = _tmp0_;
	_tmp2_ = vala_get_ccode_name ((ValaCodeNode*) st);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strconcat (_tmp3_, "*", NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = vala_ccode_function_new (_tmp1_, _tmp5_);
	_tmp7_ = _tmp6_;
	_g_free0 (_tmp5_);
	_g_free0 (_tmp3_);
	_g_free0 (_tmp1_);
	function = _tmp7_;
	_tmp8_ = vala_symbol_get_access ((ValaSymbol*) st);
	_tmp9_ = _tmp8_;
	if (_tmp9_ == VALA_SYMBOL_ACCESSIBILITY_PRIVATE) {
		ValaCCodeFunction* _tmp10_;
		_tmp10_ = function;
		vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp10_, VALA_CCODE_MODIFIERS_STATIC);
	}
	_tmp11_ = function;
	_tmp12_ = vala_get_ccode_name ((ValaCodeNode*) st);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_strconcat ("const ", _tmp13_, NULL);
	_tmp15_ = _tmp14_;
	_tmp16_ = g_strconcat (_tmp15_, "*", NULL);
	_tmp17_ = _tmp16_;
	_tmp18_ = vala_ccode_parameter_new ("self", _tmp17_);
	_tmp19_ = _tmp18_;
	vala_ccode_function_add_parameter (_tmp11_, _tmp19_);
	_vala_ccode_node_unref0 (_tmp19_);
	_g_free0 (_tmp17_);
	_g_free0 (_tmp15_);
	_g_free0 (_tmp13_);
	_tmp20_ = function;
	vala_ccode_base_module_push_function ((ValaCCodeBaseModule*) self, _tmp20_);
	_tmp21_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
	_tmp22_ = _tmp21_;
	_tmp23_ = vala_get_ccode_name ((ValaCodeNode*) st);
	_tmp24_ = _tmp23_;
	_tmp25_ = g_strconcat (_tmp24_, "*", NULL);
	_tmp26_ = _tmp25_;
	_tmp27_ = vala_ccode_variable_declarator_new ("dup", NULL, NULL);
	_tmp28_ = _tmp27_;
	vala_ccode_function_add_declaration (_tmp22_, _tmp26_, (ValaCCodeDeclarator*) _tmp28_, 0);
	_vala_ccode_node_unref0 (_tmp28_);
	_g_free0 (_tmp26_);
	_g_free0 (_tmp24_);
	_tmp29_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
	_tmp30_ = _tmp29_;
	_tmp31_ = vala_code_context_get_profile (_tmp30_);
	_tmp32_ = _tmp31_;
	if (_tmp32_ == VALA_PROFILE_GOBJECT) {
		ValaCCodeFile* _tmp33_;
		ValaCCodeFunctionCall* creation_call = NULL;
		ValaCCodeIdentifier* _tmp34_;
		ValaCCodeIdentifier* _tmp35_;
		ValaCCodeFunctionCall* _tmp36_;
		ValaCCodeFunctionCall* _tmp37_;
		ValaCCodeFunctionCall* _tmp38_;
		gchar* _tmp39_;
		gchar* _tmp40_;
		ValaCCodeConstant* _tmp41_;
		ValaCCodeConstant* _tmp42_;
		ValaCCodeFunctionCall* _tmp43_;
		ValaCCodeConstant* _tmp44_;
		ValaCCodeConstant* _tmp45_;
		ValaCCodeFunction* _tmp46_;
		ValaCCodeFunction* _tmp47_;
		ValaCCodeIdentifier* _tmp48_;
		ValaCCodeIdentifier* _tmp49_;
		ValaCCodeFunctionCall* _tmp50_;
		_tmp33_ = ((ValaCCodeBaseModule*) self)->cfile;
		vala_ccode_file_add_include (_tmp33_, "glib.h", FALSE);
		_tmp34_ = vala_ccode_identifier_new ("g_new0");
		_tmp35_ = _tmp34_;
		_tmp36_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp35_);
		_tmp37_ = _tmp36_;
		_vala_ccode_node_unref0 (_tmp35_);
		creation_call = _tmp37_;
		_tmp38_ = creation_call;
		_tmp39_ = vala_get_ccode_name ((ValaCodeNode*) st);
		_tmp40_ = _tmp39_;
		_tmp41_ = vala_ccode_constant_new (_tmp40_);
		_tmp42_ = _tmp41_;
		vala_ccode_function_call_add_argument (_tmp38_, (ValaCCodeExpression*) _tmp42_);
		_vala_ccode_node_unref0 (_tmp42_);
		_g_free0 (_tmp40_);
		_tmp43_ = creation_call;
		_tmp44_ = vala_ccode_constant_new ("1");
		_tmp45_ = _tmp44_;
		vala_ccode_function_call_add_argument (_tmp43_, (ValaCCodeExpression*) _tmp45_);
		_vala_ccode_node_unref0 (_tmp45_);
		_tmp46_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
		_tmp47_ = _tmp46_;
		_tmp48_ = vala_ccode_identifier_new ("dup");
		_tmp49_ = _tmp48_;
		_tmp50_ = creation_call;
		vala_ccode_function_add_assignment (_tmp47_, (ValaCCodeExpression*) _tmp49_, (ValaCCodeExpression*) _tmp50_);
		_vala_ccode_node_unref0 (_tmp49_);
		_vala_ccode_node_unref0 (creation_call);
	} else {
		ValaCodeContext* _tmp51_;
		ValaCodeContext* _tmp52_;
		ValaProfile _tmp53_;
		ValaProfile _tmp54_;
		_tmp51_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
		_tmp52_ = _tmp51_;
		_tmp53_ = vala_code_context_get_profile (_tmp52_);
		_tmp54_ = _tmp53_;
		if (_tmp54_ == VALA_PROFILE_POSIX) {
			ValaCCodeFile* _tmp55_;
			ValaCCodeFunctionCall* sizeof_call = NULL;
			ValaCCodeIdentifier* _tmp56_;
			ValaCCodeIdentifier* _tmp57_;
			ValaCCodeFunctionCall* _tmp58_;
			ValaCCodeFunctionCall* _tmp59_;
			ValaCCodeFunctionCall* _tmp60_;
			gchar* _tmp61_;
			gchar* _tmp62_;
			ValaCCodeConstant* _tmp63_;
			ValaCCodeConstant* _tmp64_;
			ValaCCodeFunctionCall* creation_call = NULL;
			ValaCCodeIdentifier* _tmp65_;
			ValaCCodeIdentifier* _tmp66_;
			ValaCCodeFunctionCall* _tmp67_;
			ValaCCodeFunctionCall* _tmp68_;
			ValaCCodeFunctionCall* _tmp69_;
			ValaCCodeConstant* _tmp70_;
			ValaCCodeConstant* _tmp71_;
			ValaCCodeFunctionCall* _tmp72_;
			ValaCCodeFunctionCall* _tmp73_;
			ValaCCodeFunction* _tmp74_;
			ValaCCodeFunction* _tmp75_;
			ValaCCodeIdentifier* _tmp76_;
			ValaCCodeIdentifier* _tmp77_;
			ValaCCodeFunctionCall* _tmp78_;
			_tmp55_ = ((ValaCCodeBaseModule*) self)->cfile;
			vala_ccode_file_add_include (_tmp55_, "stdlib.h", FALSE);
			_tmp56_ = vala_ccode_identifier_new ("sizeof");
			_tmp57_ = _tmp56_;
			_tmp58_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp57_);
			_tmp59_ = _tmp58_;
			_vala_ccode_node_unref0 (_tmp57_);
			sizeof_call = _tmp59_;
			_tmp60_ = sizeof_call;
			_tmp61_ = vala_get_ccode_name ((ValaCodeNode*) st);
			_tmp62_ = _tmp61_;
			_tmp63_ = vala_ccode_constant_new (_tmp62_);
			_tmp64_ = _tmp63_;
			vala_ccode_function_call_add_argument (_tmp60_, (ValaCCodeExpression*) _tmp64_);
			_vala_ccode_node_unref0 (_tmp64_);
			_g_free0 (_tmp62_);
			_tmp65_ = vala_ccode_identifier_new ("calloc");
			_tmp66_ = _tmp65_;
			_tmp67_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp66_);
			_tmp68_ = _tmp67_;
			_vala_ccode_node_unref0 (_tmp66_);
			creation_call = _tmp68_;
			_tmp69_ = creation_call;
			_tmp70_ = vala_ccode_constant_new ("1");
			_tmp71_ = _tmp70_;
			vala_ccode_function_call_add_argument (_tmp69_, (ValaCCodeExpression*) _tmp71_);
			_vala_ccode_node_unref0 (_tmp71_);
			_tmp72_ = creation_call;
			_tmp73_ = sizeof_call;
			vala_ccode_function_call_add_argument (_tmp72_, (ValaCCodeExpression*) _tmp73_);
			_tmp74_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
			_tmp75_ = _tmp74_;
			_tmp76_ = vala_ccode_identifier_new ("dup");
			_tmp77_ = _tmp76_;
			_tmp78_ = creation_call;
			vala_ccode_function_add_assignment (_tmp75_, (ValaCCodeExpression*) _tmp77_, (ValaCCodeExpression*) _tmp78_);
			_vala_ccode_node_unref0 (_tmp77_);
			_vala_ccode_node_unref0 (creation_call);
			_vala_ccode_node_unref0 (sizeof_call);
		}
	}
	if (vala_struct_is_disposable (st)) {
		ValaCCodeFunctionCall* copy_call = NULL;
		gchar* _tmp79_;
		gchar* _tmp80_;
		ValaCCodeIdentifier* _tmp81_;
		ValaCCodeIdentifier* _tmp82_;
		ValaCCodeFunctionCall* _tmp83_;
		ValaCCodeFunctionCall* _tmp84_;
		ValaCCodeFunctionCall* _tmp85_;
		ValaCCodeIdentifier* _tmp86_;
		ValaCCodeIdentifier* _tmp87_;
		ValaCCodeFunctionCall* _tmp88_;
		ValaCCodeIdentifier* _tmp89_;
		ValaCCodeIdentifier* _tmp90_;
		ValaCCodeFunction* _tmp91_;
		ValaCCodeFunction* _tmp92_;
		ValaCCodeFunctionCall* _tmp93_;
		_tmp79_ = vala_get_ccode_copy_function ((ValaTypeSymbol*) st);
		_tmp80_ = _tmp79_;
		_tmp81_ = vala_ccode_identifier_new (_tmp80_);
		_tmp82_ = _tmp81_;
		_tmp83_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp82_);
		_tmp84_ = _tmp83_;
		_vala_ccode_node_unref0 (_tmp82_);
		_g_free0 (_tmp80_);
		copy_call = _tmp84_;
		_tmp85_ = copy_call;
		_tmp86_ = vala_ccode_identifier_new ("self");
		_tmp87_ = _tmp86_;
		vala_ccode_function_call_add_argument (_tmp85_, (ValaCCodeExpression*) _tmp87_);
		_vala_ccode_node_unref0 (_tmp87_);
		_tmp88_ = copy_call;
		_tmp89_ = vala_ccode_identifier_new ("dup");
		_tmp90_ = _tmp89_;
		vala_ccode_function_call_add_argument (_tmp88_, (ValaCCodeExpression*) _tmp90_);
		_vala_ccode_node_unref0 (_tmp90_);
		_tmp91_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
		_tmp92_ = _tmp91_;
		_tmp93_ = copy_call;
		vala_ccode_function_add_expression (_tmp92_, (ValaCCodeExpression*) _tmp93_);
		_vala_ccode_node_unref0 (copy_call);
	} else {
		ValaCCodeFile* _tmp94_;
		ValaCCodeFunctionCall* sizeof_call = NULL;
		ValaCCodeIdentifier* _tmp95_;
		ValaCCodeIdentifier* _tmp96_;
		ValaCCodeFunctionCall* _tmp97_;
		ValaCCodeFunctionCall* _tmp98_;
		ValaCCodeFunctionCall* _tmp99_;
		gchar* _tmp100_;
		gchar* _tmp101_;
		ValaCCodeConstant* _tmp102_;
		ValaCCodeConstant* _tmp103_;
		ValaCCodeFunctionCall* copy_call = NULL;
		ValaCCodeIdentifier* _tmp104_;
		ValaCCodeIdentifier* _tmp105_;
		ValaCCodeFunctionCall* _tmp106_;
		ValaCCodeFunctionCall* _tmp107_;
		ValaCCodeFunctionCall* _tmp108_;
		ValaCCodeIdentifier* _tmp109_;
		ValaCCodeIdentifier* _tmp110_;
		ValaCCodeFunctionCall* _tmp111_;
		ValaCCodeIdentifier* _tmp112_;
		ValaCCodeIdentifier* _tmp113_;
		ValaCCodeFunctionCall* _tmp114_;
		ValaCCodeFunctionCall* _tmp115_;
		ValaCCodeFunction* _tmp116_;
		ValaCCodeFunction* _tmp117_;
		ValaCCodeFunctionCall* _tmp118_;
		_tmp94_ = ((ValaCCodeBaseModule*) self)->cfile;
		vala_ccode_file_add_include (_tmp94_, "string.h", FALSE);
		_tmp95_ = vala_ccode_identifier_new ("sizeof");
		_tmp96_ = _tmp95_;
		_tmp97_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp96_);
		_tmp98_ = _tmp97_;
		_vala_ccode_node_unref0 (_tmp96_);
		sizeof_call = _tmp98_;
		_tmp99_ = sizeof_call;
		_tmp100_ = vala_get_ccode_name ((ValaCodeNode*) st);
		_tmp101_ = _tmp100_;
		_tmp102_ = vala_ccode_constant_new (_tmp101_);
		_tmp103_ = _tmp102_;
		vala_ccode_function_call_add_argument (_tmp99_, (ValaCCodeExpression*) _tmp103_);
		_vala_ccode_node_unref0 (_tmp103_);
		_g_free0 (_tmp101_);
		_tmp104_ = vala_ccode_identifier_new ("memcpy");
		_tmp105_ = _tmp104_;
		_tmp106_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp105_);
		_tmp107_ = _tmp106_;
		_vala_ccode_node_unref0 (_tmp105_);
		copy_call = _tmp107_;
		_tmp108_ = copy_call;
		_tmp109_ = vala_ccode_identifier_new ("dup");
		_tmp110_ = _tmp109_;
		vala_ccode_function_call_add_argument (_tmp108_, (ValaCCodeExpression*) _tmp110_);
		_vala_ccode_node_unref0 (_tmp110_);
		_tmp111_ = copy_call;
		_tmp112_ = vala_ccode_identifier_new ("self");
		_tmp113_ = _tmp112_;
		vala_ccode_function_call_add_argument (_tmp111_, (ValaCCodeExpression*) _tmp113_);
		_vala_ccode_node_unref0 (_tmp113_);
		_tmp114_ = copy_call;
		_tmp115_ = sizeof_call;
		vala_ccode_function_call_add_argument (_tmp114_, (ValaCCodeExpression*) _tmp115_);
		_tmp116_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
		_tmp117_ = _tmp116_;
		_tmp118_ = copy_call;
		vala_ccode_function_add_expression (_tmp117_, (ValaCCodeExpression*) _tmp118_);
		_vala_ccode_node_unref0 (copy_call);
		_vala_ccode_node_unref0 (sizeof_call);
	}
	_tmp119_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
	_tmp120_ = _tmp119_;
	_tmp121_ = vala_ccode_identifier_new ("dup");
	_tmp122_ = _tmp121_;
	vala_ccode_function_add_return (_tmp120_, (ValaCCodeExpression*) _tmp122_);
	_vala_ccode_node_unref0 (_tmp122_);
	vala_ccode_base_module_pop_function ((ValaCCodeBaseModule*) self);
	_tmp123_ = ((ValaCCodeBaseModule*) self)->cfile;
	_tmp124_ = function;
	vala_ccode_file_add_function (_tmp123_, _tmp124_);
	_vala_ccode_node_unref0 (function);
}

static void
vala_ccode_struct_module_add_struct_free_function (ValaCCodeStructModule* self,
                                                   ValaStruct* st)
{
	ValaCCodeFunction* function = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	ValaCCodeFunction* _tmp2_;
	ValaCCodeFunction* _tmp3_;
	ValaCCodeFunction* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	ValaCCodeParameter* _tmp16_;
	ValaCCodeParameter* _tmp17_;
	ValaCCodeFunction* _tmp18_;
	ValaCodeContext* _tmp31_;
	ValaCodeContext* _tmp32_;
	ValaProfile _tmp33_;
	ValaProfile _tmp34_;
	ValaCCodeFile* _tmp61_;
	ValaCCodeFunction* _tmp62_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (st != NULL);
	_tmp0_ = vala_get_ccode_free_function ((ValaTypeSymbol*) st);
	_tmp1_ = _tmp0_;
	_tmp2_ = vala_ccode_function_new (_tmp1_, "void");
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	function = _tmp3_;
	if (vala_symbol_is_private_symbol ((ValaSymbol*) st)) {
		ValaCCodeFunction* _tmp4_;
		_tmp4_ = function;
		vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp4_, VALA_CCODE_MODIFIERS_STATIC);
	} else {
		gboolean _tmp5_ = FALSE;
		ValaCodeContext* _tmp6_;
		ValaCodeContext* _tmp7_;
		gboolean _tmp8_;
		gboolean _tmp9_;
		_tmp6_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
		_tmp7_ = _tmp6_;
		_tmp8_ = vala_code_context_get_hide_internal (_tmp7_);
		_tmp9_ = _tmp8_;
		if (_tmp9_) {
			_tmp5_ = vala_symbol_is_internal_symbol ((ValaSymbol*) st);
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			ValaCCodeFunction* _tmp10_;
			_tmp10_ = function;
			vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp10_, VALA_CCODE_MODIFIERS_INTERNAL);
		}
	}
	_tmp11_ = function;
	_tmp12_ = vala_get_ccode_name ((ValaCodeNode*) st);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_strconcat (_tmp13_, "*", NULL);
	_tmp15_ = _tmp14_;
	_tmp16_ = vala_ccode_parameter_new ("self", _tmp15_);
	_tmp17_ = _tmp16_;
	vala_ccode_function_add_parameter (_tmp11_, _tmp17_);
	_vala_ccode_node_unref0 (_tmp17_);
	_g_free0 (_tmp15_);
	_g_free0 (_tmp13_);
	_tmp18_ = function;
	vala_ccode_base_module_push_function ((ValaCCodeBaseModule*) self, _tmp18_);
	if (vala_struct_is_disposable (st)) {
		ValaCCodeFunctionCall* destroy_call = NULL;
		gchar* _tmp19_;
		gchar* _tmp20_;
		ValaCCodeIdentifier* _tmp21_;
		ValaCCodeIdentifier* _tmp22_;
		ValaCCodeFunctionCall* _tmp23_;
		ValaCCodeFunctionCall* _tmp24_;
		ValaCCodeFunctionCall* _tmp25_;
		ValaCCodeIdentifier* _tmp26_;
		ValaCCodeIdentifier* _tmp27_;
		ValaCCodeFunction* _tmp28_;
		ValaCCodeFunction* _tmp29_;
		ValaCCodeFunctionCall* _tmp30_;
		_tmp19_ = vala_get_ccode_destroy_function ((ValaTypeSymbol*) st);
		_tmp20_ = _tmp19_;
		_tmp21_ = vala_ccode_identifier_new (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp23_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp22_);
		_tmp24_ = _tmp23_;
		_vala_ccode_node_unref0 (_tmp22_);
		_g_free0 (_tmp20_);
		destroy_call = _tmp24_;
		_tmp25_ = destroy_call;
		_tmp26_ = vala_ccode_identifier_new ("self");
		_tmp27_ = _tmp26_;
		vala_ccode_function_call_add_argument (_tmp25_, (ValaCCodeExpression*) _tmp27_);
		_vala_ccode_node_unref0 (_tmp27_);
		_tmp28_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
		_tmp29_ = _tmp28_;
		_tmp30_ = destroy_call;
		vala_ccode_function_add_expression (_tmp29_, (ValaCCodeExpression*) _tmp30_);
		_vala_ccode_node_unref0 (destroy_call);
	}
	_tmp31_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
	_tmp32_ = _tmp31_;
	_tmp33_ = vala_code_context_get_profile (_tmp32_);
	_tmp34_ = _tmp33_;
	if (_tmp34_ == VALA_PROFILE_GOBJECT) {
		ValaCCodeFile* _tmp35_;
		ValaCCodeFunctionCall* free_call = NULL;
		ValaCCodeIdentifier* _tmp36_;
		ValaCCodeIdentifier* _tmp37_;
		ValaCCodeFunctionCall* _tmp38_;
		ValaCCodeFunctionCall* _tmp39_;
		ValaCCodeFunctionCall* _tmp40_;
		ValaCCodeIdentifier* _tmp41_;
		ValaCCodeIdentifier* _tmp42_;
		ValaCCodeFunction* _tmp43_;
		ValaCCodeFunction* _tmp44_;
		ValaCCodeFunctionCall* _tmp45_;
		_tmp35_ = ((ValaCCodeBaseModule*) self)->cfile;
		vala_ccode_file_add_include (_tmp35_, "glib.h", FALSE);
		_tmp36_ = vala_ccode_identifier_new ("g_free");
		_tmp37_ = _tmp36_;
		_tmp38_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp37_);
		_tmp39_ = _tmp38_;
		_vala_ccode_node_unref0 (_tmp37_);
		free_call = _tmp39_;
		_tmp40_ = free_call;
		_tmp41_ = vala_ccode_identifier_new ("self");
		_tmp42_ = _tmp41_;
		vala_ccode_function_call_add_argument (_tmp40_, (ValaCCodeExpression*) _tmp42_);
		_vala_ccode_node_unref0 (_tmp42_);
		_tmp43_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
		_tmp44_ = _tmp43_;
		_tmp45_ = free_call;
		vala_ccode_function_add_expression (_tmp44_, (ValaCCodeExpression*) _tmp45_);
		_vala_ccode_node_unref0 (free_call);
	} else {
		ValaCodeContext* _tmp46_;
		ValaCodeContext* _tmp47_;
		ValaProfile _tmp48_;
		ValaProfile _tmp49_;
		_tmp46_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
		_tmp47_ = _tmp46_;
		_tmp48_ = vala_code_context_get_profile (_tmp47_);
		_tmp49_ = _tmp48_;
		if (_tmp49_ == VALA_PROFILE_POSIX) {
			ValaCCodeFile* _tmp50_;
			ValaCCodeFunctionCall* free_call = NULL;
			ValaCCodeIdentifier* _tmp51_;
			ValaCCodeIdentifier* _tmp52_;
			ValaCCodeFunctionCall* _tmp53_;
			ValaCCodeFunctionCall* _tmp54_;
			ValaCCodeFunctionCall* _tmp55_;
			ValaCCodeIdentifier* _tmp56_;
			ValaCCodeIdentifier* _tmp57_;
			ValaCCodeFunction* _tmp58_;
			ValaCCodeFunction* _tmp59_;
			ValaCCodeFunctionCall* _tmp60_;
			_tmp50_ = ((ValaCCodeBaseModule*) self)->cfile;
			vala_ccode_file_add_include (_tmp50_, "stdlib.h", FALSE);
			_tmp51_ = vala_ccode_identifier_new ("free");
			_tmp52_ = _tmp51_;
			_tmp53_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp52_);
			_tmp54_ = _tmp53_;
			_vala_ccode_node_unref0 (_tmp52_);
			free_call = _tmp54_;
			_tmp55_ = free_call;
			_tmp56_ = vala_ccode_identifier_new ("self");
			_tmp57_ = _tmp56_;
			vala_ccode_function_call_add_argument (_tmp55_, (ValaCCodeExpression*) _tmp57_);
			_vala_ccode_node_unref0 (_tmp57_);
			_tmp58_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
			_tmp59_ = _tmp58_;
			_tmp60_ = free_call;
			vala_ccode_function_add_expression (_tmp59_, (ValaCCodeExpression*) _tmp60_);
			_vala_ccode_node_unref0 (free_call);
		}
	}
	vala_ccode_base_module_pop_function ((ValaCCodeBaseModule*) self);
	_tmp61_ = ((ValaCCodeBaseModule*) self)->cfile;
	_tmp62_ = function;
	vala_ccode_file_add_function (_tmp61_, _tmp62_);
	_vala_ccode_node_unref0 (function);
}

static void
vala_ccode_struct_module_add_struct_copy_function (ValaCCodeStructModule* self,
                                                   ValaStruct* st)
{
	ValaCCodeFunction* function = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	ValaCCodeFunction* _tmp2_;
	ValaCCodeFunction* _tmp3_;
	ValaCCodeFunction* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	ValaCCodeParameter* _tmp18_;
	ValaCCodeParameter* _tmp19_;
	ValaCCodeFunction* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	ValaCCodeParameter* _tmp25_;
	ValaCCodeParameter* _tmp26_;
	ValaCCodeFunction* _tmp27_;
	ValaGLibValue* dest_struct = NULL;
	ValaDataType* _tmp28_;
	ValaDataType* _tmp29_;
	ValaCCodeIdentifier* _tmp30_;
	ValaCCodeIdentifier* _tmp31_;
	ValaGLibValue* _tmp32_;
	ValaGLibValue* _tmp33_;
	ValaStruct* sym = NULL;
	ValaCCodeFile* _tmp73_;
	ValaCCodeFunction* _tmp74_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (st != NULL);
	_tmp0_ = vala_get_ccode_copy_function ((ValaTypeSymbol*) st);
	_tmp1_ = _tmp0_;
	_tmp2_ = vala_ccode_function_new (_tmp1_, "void");
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	function = _tmp3_;
	if (vala_symbol_is_private_symbol ((ValaSymbol*) st)) {
		ValaCCodeFunction* _tmp4_;
		_tmp4_ = function;
		vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp4_, VALA_CCODE_MODIFIERS_STATIC);
	} else {
		gboolean _tmp5_ = FALSE;
		ValaCodeContext* _tmp6_;
		ValaCodeContext* _tmp7_;
		gboolean _tmp8_;
		gboolean _tmp9_;
		_tmp6_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
		_tmp7_ = _tmp6_;
		_tmp8_ = vala_code_context_get_hide_internal (_tmp7_);
		_tmp9_ = _tmp8_;
		if (_tmp9_) {
			_tmp5_ = vala_symbol_is_internal_symbol ((ValaSymbol*) st);
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			ValaCCodeFunction* _tmp10_;
			_tmp10_ = function;
			vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp10_, VALA_CCODE_MODIFIERS_INTERNAL);
		}
	}
	_tmp11_ = function;
	_tmp12_ = vala_get_ccode_name ((ValaCodeNode*) st);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_strconcat ("const ", _tmp13_, NULL);
	_tmp15_ = _tmp14_;
	_tmp16_ = g_strconcat (_tmp15_, "*", NULL);
	_tmp17_ = _tmp16_;
	_tmp18_ = vala_ccode_parameter_new ("self", _tmp17_);
	_tmp19_ = _tmp18_;
	vala_ccode_function_add_parameter (_tmp11_, _tmp19_);
	_vala_ccode_node_unref0 (_tmp19_);
	_g_free0 (_tmp17_);
	_g_free0 (_tmp15_);
	_g_free0 (_tmp13_);
	_tmp20_ = function;
	_tmp21_ = vala_get_ccode_name ((ValaCodeNode*) st);
	_tmp22_ = _tmp21_;
	_tmp23_ = g_strconcat (_tmp22_, "*", NULL);
	_tmp24_ = _tmp23_;
	_tmp25_ = vala_ccode_parameter_new ("dest", _tmp24_);
	_tmp26_ = _tmp25_;
	vala_ccode_function_add_parameter (_tmp20_, _tmp26_);
	_vala_ccode_node_unref0 (_tmp26_);
	_g_free0 (_tmp24_);
	_g_free0 (_tmp22_);
	_tmp27_ = function;
	vala_ccode_base_module_push_function ((ValaCCodeBaseModule*) self, _tmp27_);
	_tmp28_ = vala_semantic_analyzer_get_data_type_for_symbol ((ValaSymbol*) st);
	_tmp29_ = _tmp28_;
	_tmp30_ = vala_ccode_identifier_new ("(*dest)");
	_tmp31_ = _tmp30_;
	_tmp32_ = vala_glib_value_new (_tmp29_, (ValaCCodeExpression*) _tmp31_, TRUE);
	_tmp33_ = _tmp32_;
	_vala_ccode_node_unref0 (_tmp31_);
	_vala_code_node_unref0 (_tmp29_);
	dest_struct = _tmp33_;
	sym = st;
	while (TRUE) {
		ValaStruct* _tmp34_;
		ValaStruct* _tmp35_;
		ValaStruct* _tmp36_;
		ValaStruct* _tmp37_;
		ValaStruct* _tmp38_;
		ValaStruct* _tmp39_;
		_tmp34_ = sym;
		_tmp35_ = vala_struct_get_base_struct (_tmp34_);
		_tmp36_ = _tmp35_;
		if (!(_tmp36_ != NULL)) {
			break;
		}
		_tmp37_ = sym;
		_tmp38_ = vala_struct_get_base_struct (_tmp37_);
		_tmp39_ = _tmp38_;
		sym = _tmp39_;
	}
	{
		ValaList* _f_list = NULL;
		ValaStruct* _tmp40_;
		ValaList* _tmp41_;
		gint _f_size = 0;
		ValaList* _tmp42_;
		gint _tmp43_;
		gint _tmp44_;
		gint _f_index = 0;
		_tmp40_ = sym;
		_tmp41_ = vala_struct_get_fields (_tmp40_);
		_f_list = _tmp41_;
		_tmp42_ = _f_list;
		_tmp43_ = vala_collection_get_size ((ValaCollection*) _tmp42_);
		_tmp44_ = _tmp43_;
		_f_size = _tmp44_;
		_f_index = -1;
		while (TRUE) {
			gint _tmp45_;
			gint _tmp46_;
			ValaField* f = NULL;
			ValaList* _tmp47_;
			gpointer _tmp48_;
			ValaField* _tmp49_;
			ValaMemberBinding _tmp50_;
			ValaMemberBinding _tmp51_;
			_f_index = _f_index + 1;
			_tmp45_ = _f_index;
			_tmp46_ = _f_size;
			if (!(_tmp45_ < _tmp46_)) {
				break;
			}
			_tmp47_ = _f_list;
			_tmp48_ = vala_list_get (_tmp47_, _f_index);
			f = (ValaField*) _tmp48_;
			_tmp49_ = f;
			_tmp50_ = vala_field_get_binding (_tmp49_);
			_tmp51_ = _tmp50_;
			if (_tmp51_ == VALA_MEMBER_BINDING_INSTANCE) {
				ValaTargetValue* value = NULL;
				ValaField* _tmp52_;
				ValaTargetValue* _tmp53_;
				ValaTargetValue* _tmp54_;
				ValaTargetValue* _tmp55_;
				ValaTargetValue* _tmp56_;
				gboolean _tmp57_ = FALSE;
				gboolean _tmp58_ = FALSE;
				ValaField* _tmp59_;
				ValaDataType* _tmp60_;
				ValaDataType* _tmp61_;
				ValaField* _tmp70_;
				ValaGLibValue* _tmp71_;
				ValaTargetValue* _tmp72_;
				_tmp52_ = f;
				_tmp53_ = vala_ccode_base_module_load_this_parameter ((ValaCCodeBaseModule*) self, G_TYPE_CHECK_INSTANCE_CAST (st, VALA_TYPE_TYPESYMBOL, ValaTypeSymbol));
				_tmp54_ = _tmp53_;
				_tmp55_ = vala_code_generator_load_field ((ValaCodeGenerator*) self, _tmp52_, _tmp54_, NULL);
				_tmp56_ = _tmp55_;
				_vala_target_value_unref0 (_tmp54_);
				value = _tmp56_;
				_tmp59_ = f;
				_tmp60_ = vala_variable_get_variable_type ((ValaVariable*) _tmp59_);
				_tmp61_ = _tmp60_;
				if (!G_TYPE_CHECK_INSTANCE_TYPE (_tmp61_, VALA_TYPE_DELEGATE_TYPE)) {
					_tmp58_ = TRUE;
				} else {
					ValaField* _tmp62_;
					_tmp62_ = f;
					_tmp58_ = vala_get_ccode_delegate_target ((ValaCodeNode*) _tmp62_);
				}
				if (_tmp58_) {
					ValaField* _tmp63_;
					ValaDataType* _tmp64_;
					ValaDataType* _tmp65_;
					_tmp63_ = f;
					_tmp64_ = vala_variable_get_variable_type ((ValaVariable*) _tmp63_);
					_tmp65_ = _tmp64_;
					_tmp57_ = vala_ccode_base_module_requires_copy (_tmp65_);
				} else {
					_tmp57_ = FALSE;
				}
				if (_tmp57_) {
					ValaTargetValue* _tmp66_;
					ValaField* _tmp67_;
					ValaTargetValue* _tmp68_;
					ValaTargetValue* _tmp69_;
					_tmp66_ = value;
					_tmp67_ = f;
					_tmp68_ = vala_ccode_base_module_copy_value ((ValaCCodeBaseModule*) self, _tmp66_, (ValaCodeNode*) _tmp67_);
					_vala_target_value_unref0 (value);
					value = _tmp68_;
					_tmp69_ = value;
					if (_tmp69_ == NULL) {
						_vala_target_value_unref0 (value);
						_vala_code_node_unref0 (f);
						continue;
					}
				}
				_tmp70_ = f;
				_tmp71_ = dest_struct;
				_tmp72_ = value;
				vala_code_generator_store_field ((ValaCodeGenerator*) self, _tmp70_, (ValaTargetValue*) _tmp71_, _tmp72_, NULL);
				_vala_target_value_unref0 (value);
			}
			_vala_code_node_unref0 (f);
		}
	}
	vala_ccode_base_module_pop_function ((ValaCCodeBaseModule*) self);
	_tmp73_ = ((ValaCCodeBaseModule*) self)->cfile;
	_tmp74_ = function;
	vala_ccode_file_add_function (_tmp73_, _tmp74_);
	_vala_target_value_unref0 (dest_struct);
	_vala_ccode_node_unref0 (function);
}

static void
vala_ccode_struct_module_begin_struct_destroy_function (ValaCCodeStructModule* self,
                                                        ValaStruct* st)
{
	ValaCCodeBaseModuleEmitContext* _tmp0_;
	ValaCCodeFunction* function = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_;
	ValaCCodeFunction* _tmp3_;
	ValaCCodeFunction* _tmp4_;
	ValaCCodeFunction* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	ValaCCodeParameter* _tmp17_;
	ValaCCodeParameter* _tmp18_;
	ValaCCodeFunction* _tmp19_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (st != NULL);
	_tmp0_ = ((ValaCCodeBaseModule*) self)->instance_finalize_context;
	vala_ccode_base_module_push_context ((ValaCCodeBaseModule*) self, _tmp0_);
	_tmp1_ = vala_get_ccode_destroy_function ((ValaTypeSymbol*) st);
	_tmp2_ = _tmp1_;
	_tmp3_ = vala_ccode_function_new (_tmp2_, "void");
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	function = _tmp4_;
	if (vala_symbol_is_private_symbol ((ValaSymbol*) st)) {
		ValaCCodeFunction* _tmp5_;
		_tmp5_ = function;
		vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp5_, VALA_CCODE_MODIFIERS_STATIC);
	} else {
		gboolean _tmp6_ = FALSE;
		ValaCodeContext* _tmp7_;
		ValaCodeContext* _tmp8_;
		gboolean _tmp9_;
		gboolean _tmp10_;
		_tmp7_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
		_tmp8_ = _tmp7_;
		_tmp9_ = vala_code_context_get_hide_internal (_tmp8_);
		_tmp10_ = _tmp9_;
		if (_tmp10_) {
			_tmp6_ = vala_symbol_is_internal_symbol ((ValaSymbol*) st);
		} else {
			_tmp6_ = FALSE;
		}
		if (_tmp6_) {
			ValaCCodeFunction* _tmp11_;
			_tmp11_ = function;
			vala_ccode_node_set_modifiers ((ValaCCodeNode*) _tmp11_, VALA_CCODE_MODIFIERS_INTERNAL);
		}
	}
	_tmp12_ = function;
	_tmp13_ = vala_get_ccode_name ((ValaCodeNode*) st);
	_tmp14_ = _tmp13_;
	_tmp15_ = g_strconcat (_tmp14_, "*", NULL);
	_tmp16_ = _tmp15_;
	_tmp17_ = vala_ccode_parameter_new ("self", _tmp16_);
	_tmp18_ = _tmp17_;
	vala_ccode_function_add_parameter (_tmp12_, _tmp18_);
	_vala_ccode_node_unref0 (_tmp18_);
	_g_free0 (_tmp16_);
	_g_free0 (_tmp14_);
	_tmp19_ = function;
	vala_ccode_base_module_push_function ((ValaCCodeBaseModule*) self, _tmp19_);
	vala_ccode_base_module_pop_context ((ValaCCodeBaseModule*) self);
	_vala_ccode_node_unref0 (function);
}

static void
vala_ccode_struct_module_add_struct_destroy_function (ValaCCodeStructModule* self,
                                                      ValaStruct* st)
{
	ValaStruct* sym = NULL;
	ValaStruct* _tmp6_;
	ValaCCodeFile* _tmp21_;
	ValaCCodeBaseModuleEmitContext* _tmp22_;
	ValaCCodeFunction* _tmp23_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (st != NULL);
	sym = st;
	while (TRUE) {
		ValaStruct* _tmp0_;
		ValaStruct* _tmp1_;
		ValaStruct* _tmp2_;
		ValaStruct* _tmp3_;
		ValaStruct* _tmp4_;
		ValaStruct* _tmp5_;
		_tmp0_ = sym;
		_tmp1_ = vala_struct_get_base_struct (_tmp0_);
		_tmp2_ = _tmp1_;
		if (!(_tmp2_ != NULL)) {
			break;
		}
		_tmp3_ = sym;
		_tmp4_ = vala_struct_get_base_struct (_tmp3_);
		_tmp5_ = _tmp4_;
		sym = _tmp5_;
	}
	_tmp6_ = sym;
	if (st != _tmp6_) {
		ValaCCodeBaseModuleEmitContext* _tmp7_;
		ValaCCodeFunctionCall* destroy_func = NULL;
		ValaStruct* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		ValaCCodeIdentifier* _tmp11_;
		ValaCCodeIdentifier* _tmp12_;
		ValaCCodeFunctionCall* _tmp13_;
		ValaCCodeFunctionCall* _tmp14_;
		ValaCCodeFunctionCall* _tmp15_;
		ValaCCodeIdentifier* _tmp16_;
		ValaCCodeIdentifier* _tmp17_;
		ValaCCodeFunction* _tmp18_;
		ValaCCodeFunction* _tmp19_;
		ValaCCodeFunctionCall* _tmp20_;
		_tmp7_ = ((ValaCCodeBaseModule*) self)->instance_finalize_context;
		vala_ccode_base_module_push_context ((ValaCCodeBaseModule*) self, _tmp7_);
		_tmp8_ = sym;
		_tmp9_ = vala_get_ccode_destroy_function ((ValaTypeSymbol*) _tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = vala_ccode_identifier_new (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp12_);
		_tmp14_ = _tmp13_;
		_vala_ccode_node_unref0 (_tmp12_);
		_g_free0 (_tmp10_);
		destroy_func = _tmp14_;
		_tmp15_ = destroy_func;
		_tmp16_ = vala_ccode_identifier_new ("self");
		_tmp17_ = _tmp16_;
		vala_ccode_function_call_add_argument (_tmp15_, (ValaCCodeExpression*) _tmp17_);
		_vala_ccode_node_unref0 (_tmp17_);
		_tmp18_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
		_tmp19_ = _tmp18_;
		_tmp20_ = destroy_func;
		vala_ccode_function_add_expression (_tmp19_, (ValaCCodeExpression*) _tmp20_);
		vala_ccode_base_module_pop_context ((ValaCCodeBaseModule*) self);
		_vala_ccode_node_unref0 (destroy_func);
	}
	_tmp21_ = ((ValaCCodeBaseModule*) self)->cfile;
	_tmp22_ = ((ValaCCodeBaseModule*) self)->instance_finalize_context;
	_tmp23_ = _tmp22_->ccode;
	vala_ccode_file_add_function (_tmp21_, _tmp23_);
}

ValaCCodeStructModule*
vala_ccode_struct_module_construct (GType object_type)
{
	ValaCCodeStructModule* self = NULL;
	self = (ValaCCodeStructModule*) vala_ccode_base_module_construct (object_type);
	return self;
}

static void
vala_ccode_struct_module_class_init (ValaCCodeStructModuleClass * klass,
                                     gpointer klass_data)
{
	vala_ccode_struct_module_parent_class = g_type_class_peek_parent (klass);
	((ValaCCodeBaseModuleClass *) klass)->generate_struct_declaration = (void (*) (ValaCCodeBaseModule*, ValaStruct*, ValaCCodeFile*)) vala_ccode_struct_module_real_generate_struct_declaration;
	((ValaCodeVisitorClass *) klass)->visit_struct = (void (*) (ValaCodeVisitor*, ValaStruct*)) vala_ccode_struct_module_real_visit_struct;
}

static void
vala_ccode_struct_module_instance_init (ValaCCodeStructModule * self,
                                        gpointer klass)
{
}

static GType
vala_ccode_struct_module_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeStructModuleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_struct_module_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeStructModule), 0, (GInstanceInitFunc) vala_ccode_struct_module_instance_init, NULL };
	GType vala_ccode_struct_module_type_id;
	vala_ccode_struct_module_type_id = g_type_register_static (VALA_TYPE_CCODE_BASE_MODULE, "ValaCCodeStructModule", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return vala_ccode_struct_module_type_id;
}

GType
vala_ccode_struct_module_get_type (void)
{
	static volatile gsize vala_ccode_struct_module_type_id__once = 0;
	if (g_once_init_enter (&vala_ccode_struct_module_type_id__once)) {
		GType vala_ccode_struct_module_type_id;
		vala_ccode_struct_module_type_id = vala_ccode_struct_module_get_type_once ();
		g_once_init_leave (&vala_ccode_struct_module_type_id__once, vala_ccode_struct_module_type_id);
	}
	return vala_ccode_struct_module_type_id__once;
}

