#include "run-time.h"

/* Typedefs for referenced classes */

typedef struct {
  D wrapper;
  D instanceQ_iep_;
  D debug_name_;
  D class_implementation_class_;
  D class_subtype_bit_;
  D class_module_;
} _KLclassGVKd;

#define  define__KLmm_wrapperGVKi(nrepeated) \
  typedef struct { \
    D wrapper; \
    D mm_wrapper_implementation_class_; \
    D mm_wrapper_subtype_mask_; \
    DWORD mm_wrapper_fixed_part_; \
    DWORD mm_wrapper_variable_part_; \
    D mm_wrapper_number_patterns_; \
    DWORD mm_wrapper_pattern_element_[nrepeated+1]; \
  } _KLmm_wrapperGVKi_##nrepeated;
define__KLmm_wrapperGVKi(1);
define__KLmm_wrapperGVKi(0);

typedef struct {
  D wrapper;
} _KLobjectGVKd;

typedef struct {
  D wrapper;
} _KLunboundGVKe;

typedef struct {
  D wrapper;
} _KLbooleanGVKd;

typedef struct {
  D wrapper;
  D xep_;
  D function_signature_;
  D Pgf_cache_;
  D debug_name_;
  D generic_function_methods_;
  D discriminator_;
  D incremental_gf_module_;
  D incremental_gf_domain_info_;
  D incremental_gf_method_libraries_;
  D incremental_gf_properties_;
} _KLincremental_generic_functionGVKe;

typedef struct {
  D wrapper;
  D instanceQ_iep_;
  D debug_name_;
  D class_implementation_class_;
  D class_subtype_bit_;
  D class_module_;
} _KLfunction_classGVKi;

typedef struct {
  D wrapper;
  D head_;
  D tail_;
} _KLempty_listGVKd;

typedef struct {
  D wrapper;
  D properties_;
  D engine_node_callback_;
  D engine_node_entry_point_;
} _KLabsent_engine_nodeGVKg;

typedef struct {
  D wrapper;
  D namespace_name_;
  D home_library_;
} _KLmoduleGVKe;

#define  define__KLsimple_object_vectorGVKd(nrepeated) \
  typedef struct { \
    D wrapper; \
    D size_; \
    D vector_element_[nrepeated+1]; \
  } _KLsimple_object_vectorGVKd_##nrepeated;
define__KLsimple_object_vectorGVKd(1);
define__KLsimple_object_vectorGVKd(7);
define__KLsimple_object_vectorGVKd(4);
define__KLsimple_object_vectorGVKd(0);

#define  define__KLbyte_stringGVKd(nrepeated) \
  typedef struct { \
    D wrapper; \
    D size_; \
    char string_element_[nrepeated+1]; \
  } _KLbyte_stringGVKd_##nrepeated;
define__KLbyte_stringGVKd(34);
define__KLbyte_stringGVKd(8);
define__KLbyte_stringGVKd(7);
define__KLbyte_stringGVKd(14);

typedef struct {
  D wrapper;
  D signature_properties_;
  D signature_required_;
  D signature_values_;
} _KLsignatureAvaluesGVKi;

typedef struct {
  D wrapper;
  D private_lambda_name_internal_;
  D private_lambda_location_;
  D private_lambda_all_locators_;
  D private_lambda_selected_locators_internal_;
  D private_lambda_variable_scopes_internal_;
  D private_lambda_all_variable_scopes_;
  D private_lambda_all_variable_names_;
  D compiled_lambda_packed_slot_;
} _KLcompiled_lambdaGYbase_harpVharp;

typedef struct {
  D wrapper;
  D mangler_;
  D cg_variables_;
  D registers_;
  D variables_;
} _KLharp_back_endGYbase_harpVharp;

typedef struct {
  D wrapper;
  D head_;
  D tail_;
} _KLpairGVKd;

typedef struct {
  D wrapper;
  D symbol_name_;
} _KLsymbolGVKd;

typedef struct {
  D wrapper;
  D outer_stream_;
  D private_stream_element_type_value_;
  D private_stream_direction_value_;
  D private_stream_lock_value_;
  D initial_position_;
  D current_position_;
  D final_position_;
  D stream_sequence_;
  D stream_limit_;
} _KLstring_streamGYstreamsVio;

typedef struct {
  D wrapper;
  D xep_;
  D function_signature_;
  D mep_;
} _KLsimple_methodGVKe;

typedef struct {
  D wrapper;
  D signature_properties_;
  D signature_required_;
} _KLsignatureGVKe;


/* Typedefs for defined classes */


/* Referenced object declarations */

extern _KLclassGVKd KLclassGVKd;
extern _KLmm_wrapperGVKi_0 KLclassGVKdW;
extern _KLclassGVKd KLmm_wrapperGVKi;
extern _KLmm_wrapperGVKi_1 KLmm_wrapperGVKiW;
extern _KLclassGVKd KLobjectGVKd;
extern _KLmm_wrapperGVKi_0 KLobjectGVKdW;
extern _KLunboundGVKe KPunboundVKi;
extern _KLclassGVKd KLunboundGVKe;
extern _KLmm_wrapperGVKi_0 KLunboundGVKeW;
extern _KLbooleanGVKd KPtrueVKi;
extern _KLclassGVKd KLbooleanGVKd;
extern _KLmm_wrapperGVKi_0 KLbooleanGVKdW;
extern _KLbooleanGVKd KPfalseVKi;
extern _KLfunction_classGVKi KLincremental_generic_functionGVKe;
extern _KLclassGVKd KLfunction_classGVKi;
extern _KLmm_wrapperGVKi_0 KLfunction_classGVKiW;
extern _KLmm_wrapperGVKi_0 KLincremental_generic_functionGVKeW;
extern _KLempty_listGVKd KPempty_listVKi;
extern _KLclassGVKd KLempty_listGVKd;
extern _KLmm_wrapperGVKi_0 KLempty_listGVKdW;
extern _KLabsent_engine_nodeGVKg RSINGULAR_Labsent_engine_nodeG;
extern _KLclassGVKd KLabsent_engine_nodeGVKg;
extern _KLmm_wrapperGVKi_0 KLabsent_engine_nodeGVKgW;
extern _KLmoduleGVKe Kmain_harp_moduleYdylan_userVharp;
extern _KLclassGVKd KLmoduleGVKe;
extern _KLmm_wrapperGVKi_0 KLmoduleGVKeW;
extern _KLsimple_object_vectorGVKd_0 KPempty_vectorVKi;
extern _KLclassGVKd KLsimple_object_vectorGVKd;
extern _KLmm_wrapperGVKi_0 KLsimple_object_vectorGVKdW;
extern _KLclassGVKd KLbyte_stringGVKd;
extern _KLmm_wrapperGVKi_0 KLbyte_stringGVKdW;
extern _KLclassGVKd KLsignatureAvaluesGVKi;
extern _KLmm_wrapperGVKi_0 KLsignatureAvaluesGVKiW;
extern _KLclassGVKd KLcompiled_lambdaGYbase_harpVharp;
extern _KLmm_wrapperGVKi_0 KLcompiled_lambdaGYbase_harpVharpW;
extern _KLclassGVKd KLharp_back_endGYbase_harpVharp;
extern _KLmm_wrapperGVKi_0 KLharp_back_endGYbase_harpVharpW;
extern _KLclassGVKd KLpairGVKd;
extern _KLmm_wrapperGVKi_0 KLpairGVKdW;
D KmakeVKdMM33I (D, D, D, D);
extern _KLsymbolGVKd KJdirection_;
extern _KLclassGVKd KLsymbolGVKd;
extern _KLmm_wrapperGVKi_0 KLsymbolGVKdW;
extern _KLsymbolGVKd KJoutput_;
extern _KLincremental_generic_functionGVKe KmakeVKd;
extern _KLclassGVKd KLstring_streamGYstreamsVio;
extern _KLmm_wrapperGVKi_0 KLstring_streamGYstreamsVioW;
D Kcode_gen_from_blockYmain_harpVharpMM0I (D backend_, D top_blck_, D print_harp_);
D Kresolve_sdisYmain_harpVharpMM0I (D);
extern _KLincremental_generic_functionGVKe Kstream_contents_asYstreams_protocolVcommon_dylan;
D Kassemble_compiled_lambdaYmain_harpVharpMM0I (D, D, D, D, D);
extern _KLincremental_generic_functionGVKe Koutput_compiled_lambdaYharp_outputterVharp;
extern _KLfunction_classGVKi KLsimple_methodGVKe;
extern _KLmm_wrapperGVKi_0 KLsimple_methodGVKeW;
D Kins__remYharp_instructionsVharpMM0I (D, D);
D Kmake_fall_thru_bbYbase_harpVharpMM0I (D);
extern _KLclassGVKd KLsignatureGVKe;
extern _KLmm_wrapperGVKi_0 KLsignatureGVKeW;

/* Defined object declarations */

D Kpre_cg_lambdaYmain_harpVharpMM0I (D);
extern _KLincremental_generic_functionGVKe Kpost_cg_lambdaYmain_harpVharp;
extern _KLsimple_methodGVKe Kpost_cg_lambdaYmain_harpVharpMM0;
D Kpost_cg_lambdaYmain_harpVharpMM0I (D, D, D, D, D, D, D);
static _KLpairGVKd K4;
static _KLsignatureAvaluesGVKi K5;
static _KLbyte_stringGVKd_14 K6;
static _KLsimple_object_vectorGVKd_7 K7;
static _KLsimple_object_vectorGVKd_1 K8;
static _KLsymbolGVKd KJcontents_;
static _KLsymbolGVKd KJsection_;
static _KLbyte_stringGVKd_7 K11;
static _KLbyte_stringGVKd_8 K12;
static _KLbyte_stringGVKd_34 K13;
extern _KLsimple_methodGVKe Kpre_cg_lambdaYmain_harpVharpMM0;
static _KLsignatureGVKe K15;
static _KLsimple_object_vectorGVKd_1 K16;

/* Indirection variables */

static D IKJcontents_ = &KJcontents_;
static D IKJsection_ = &KJsection_;

/* Variables */

D pre_cg_lambdaYmain_harpVharp = &Kpre_cg_lambdaYmain_harpVharpMM0;
D post_cg_lambdaYmain_harpVharp = &Kpost_cg_lambdaYmain_harpVharp;

/* Objects */

_KLincremental_generic_functionGVKe Kpost_cg_lambdaYmain_harpVharp = {
  &KLincremental_generic_functionGVKeW /* wrapper */,
  &gf_xep_7,
  &K5,
  (D) 1,
  &K6,
  &K4,
  &RSINGULAR_Labsent_engine_nodeG,
  &Kmain_harp_moduleYdylan_userVharp,
  &KPfalseVKi,
  &KPempty_vectorVKi,
  (D) 25
};

_KLsimple_methodGVKe Kpost_cg_lambdaYmain_harpVharpMM0 = {
  &KLsimple_methodGVKeW /* wrapper */,
  &xep_7,
  &K5,
  &Kpost_cg_lambdaYmain_harpVharpMM0I
};

static _KLpairGVKd K4 = {
  &KLpairGVKdW /* wrapper */,
  &Kpost_cg_lambdaYmain_harpVharpMM0,
  &KPempty_listVKi
};

static _KLsignatureAvaluesGVKi K5 = {
  &KLsignatureAvaluesGVKiW /* wrapper */,
  (D) 33555485,
  &K7,
  &K8
};

static _KLbyte_stringGVKd_14 K6 = {
  &KLbyte_stringGVKdW /* wrapper */,
  (D) 57,
  "post-cg-lambda"
};

static _KLsimple_object_vectorGVKd_7 K7 = {
  &KLsimple_object_vectorGVKdW /* wrapper */,
  (D) 29,
  &KLharp_back_endGYbase_harpVharp,
  &KLobjectGVKd,
  &KLobjectGVKd,
  &KLobjectGVKd,
  &KLobjectGVKd,
  &KLobjectGVKd,
  &KLobjectGVKd
};

static _KLsimple_object_vectorGVKd_1 K8 = {
  &KLsimple_object_vectorGVKdW /* wrapper */,
  (D) 5,
  &KLcompiled_lambdaGYbase_harpVharp
};

static _KLsymbolGVKd KJcontents_ = {
  &KLsymbolGVKdW /* wrapper */,
  &K12
};

static _KLsymbolGVKd KJsection_ = {
  &KLsymbolGVKdW /* wrapper */,
  &K11
};

static _KLbyte_stringGVKd_7 K11 = {
  &KLbyte_stringGVKdW /* wrapper */,
  (D) 29,
  "section"
};

static _KLbyte_stringGVKd_8 K12 = {
  &KLbyte_stringGVKdW /* wrapper */,
  (D) 33,
  "contents"
};

static _KLbyte_stringGVKd_34 K13 = {
  &KLbyte_stringGVKdW /* wrapper */,
  (D) 137,
  "This is a dummy first basic block."
};

_KLsimple_methodGVKe Kpre_cg_lambdaYmain_harpVharpMM0 = {
  &KLsimple_methodGVKeW /* wrapper */,
  &xep_1,
  &K15,
  &Kpre_cg_lambdaYmain_harpVharpMM0I
};

static _KLsignatureGVKe K15 = {
  &KLsignatureGVKeW /* wrapper */,
  (D) 41943045,
  &K16
};

static _KLsimple_object_vectorGVKd_1 K16 = {
  &KLsimple_object_vectorGVKdW /* wrapper */,
  (D) 5,
  &KLharp_back_endGYbase_harpVharp
};

/* Code */

D Kpre_cg_lambdaYmain_harpVharpMM0I (D backend_) {
  D T2;

  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:20
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:21
  Kins__remYharp_instructionsVharpMM0I(backend_, &K13);
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:22
  T2 = Kmake_fall_thru_bbYbase_harpVharpMM0I(backend_);
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:20
  MV_SET_COUNT(0);
  return(T2);
}

D Kpost_cg_lambdaYmain_harpVharpMM0I (D backend_, D outputter_, D harp_debugQ_, D publicQ_, D exportQ_, D source_locator_, D section_) {
  D T8;
  D print_stream_;
  D T10;
  D print_info_;
  D compiled_lambda_;
  D T13_0;
  D T14;
  D T15;
  D T16;
  _KLsimple_object_vectorGVKd_4 T17 = {&KLsimple_object_vectorGVKdW, (D) 17};

  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:46
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:50
  T14 = SLOT_VALUE(backend_, 3);
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:51
  T15 = SLOT_VALUE(T14, 3);
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:53
  if (harp_debugQ_ != &KPfalseVKi) {
    // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:55
    T16 = KmakeVKdMM33I(&KLbyte_stringGVKd, &KPempty_vectorVKi, C(' '), (D) 4001);
    // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:54
    T17.vector_element_[0] = &KJdirection_;
    T17.vector_element_[1] = &KJoutput_;
    T17.vector_element_[2] = IKJcontents_;
    T17.vector_element_[3] = T16;
    // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:54
    CONGRUENT_CALL_PROLOG(&KmakeVKd, 2);
    T8 = CONGRUENT_CALL2(&KLstring_streamGYstreamsVio, &T17);
    print_stream_ = T8;
  } else {
    print_stream_ = &KPfalseVKi;
  }
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:53
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:58
  Kcode_gen_from_blockYmain_harpVharpMM0I(backend_, T15, print_stream_);
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:59
  Kresolve_sdisYmain_harpVharpMM0I(backend_);
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:61
  if (harp_debugQ_ != &KPfalseVKi) {
    // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:62
    T10 = CALL2(&Kstream_contents_asYstreams_protocolVcommon_dylan, &KLbyte_stringGVKd, print_stream_);
    print_info_ = T10;
  } else {
    print_info_ = &KPfalseVKi;
  }
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:61
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:66
  compiled_lambda_ = Kassemble_compiled_lambdaYmain_harpVharpMM0I(backend_, print_info_, publicQ_, exportQ_, source_locator_);
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:67
  if (outputter_ != &KPfalseVKi) {
    // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:68
    CALL5(&Koutput_compiled_lambdaYharp_outputterVharp, backend_, outputter_, compiled_lambda_, IKJsection_, section_);
  }
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:67
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:70
  T13_0 = compiled_lambda_;
  // /Users/bruce/Development/dylan/opendylan/sources/harp/core-harp/post-cg-lambda.dylan:46
  MV_SET_COUNT(1);
  return(T13_0);
}


/* SYSTEM INIT CODE */

void _Init_harp__X_post_cg_lambda_for_system () {
  extern D KPresolve_symbolVKiI(D);
  {
    D T0;

    T0 = KPresolve_symbolVKiI(&KJcontents_);
    if (T0 != &KJcontents_) {
      IKJcontents_ = T0;
    }
  }
  {
    D T0;

    T0 = KPresolve_symbolVKiI(&KJsection_);
    if (T0 != &KJsection_) {
      IKJsection_ = T0;
    }
  }
  return;
}

/* USER INIT CODE */

void _Init_harp__X_post_cg_lambda_for_user () {
  return;
}


/* eof */
