#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr scope_methods[meth_max];
extern cptr identifier_methods[meth_max];
extern cptr string_methods[meth_max];
extern cptr variable_methods[meth_max];
#include "croutine.h"
extern cptr stdout_methods[meth_max];
extern cptr integer_methods[meth_max];
extern cptr strpool_methods[meth_max];
extern cptr clib_methods[meth_max];
#include "cprocess.h"
#include "cstring.h"
extern cptr debug_methods[meth_max];
#include "cfile.h"
extern cptr parameter_methods[meth_max];
extern cptr exprfunc_methods[meth_max];
extern cptr slist_methods[meth_max];

extern cint object_Undefined;
extern cint clib_Trace;
extern cint clib_stdo;
extern cint scope_curr;
extern cint strpool_str_13;
extern cint strpool_str_15;
extern cint strpool_str_37;
extern cint strpool_str_85;
extern cint strpool_str_86;

cint function_Calling_scope;

cptr function_methods[meth_max];

cint function_alloc(cint function_self, cint function_b, cint function_id, cint function_mid){
  cint function_result;
  cint t1, t2, t3;
  t2 = object_alloc((cint)function_self);
  function_result = t2;
  ((cptr)function_self)[4] /* class_of*/ = strpool_str_37;
  ((cptr)function_self)[7] /* module*/ = function_mid;
  ((cptr)((cptr)function_id)[7] /* name*/)[1] += 1;
  ((cptr)function_self)[8] /* name*/ = ((cptr)function_id)[7] /* name*/;
  ((cptr)function_self)[9] /* body*/ = function_b;
  ((cptr)function_self)[10] /* efunc*/ = 0;
  t3 = (cptr)(((cptr)(((cptr)scope_curr)[0]))[121]); /* enter_into*/
  ((f0)t3)((cint)scope_curr, (cint)((cptr)function_id)[7] /* name*/, (cint)function_self);
  ((cptr)function_self)[11] /* escope*/ = scope_curr;
  ((cptr)function_self)[12] /* memo*/ = object_Undefined;
  object_Dec_ref(function_id);
  t1 = function_result;
  goto t1_label;
  t1_label: return t1;
}

cint function_alloc_new(cint function_p, cint function_id, cint function_scop){
  cint function_result, function_saved_curr;
  cint t4, t5, t6;
  function_saved_curr = scope_curr;
  scope_curr = function_scop;
  t5 = mem_malloc(52); ((cptr)t5)[0] = function_methods;
  t6 = function_alloc((cint)t5, (cint)0, (cint)function_id, (cint)0);
  function_result = t6;
  ((cptr)function_result)[10] /* efunc*/ = function_p;
  scope_curr = function_saved_curr;
  t4 = function_result;
  goto t4_label;
  t4_label: return t4;
}

cint function_reclaim(cint function_self){
  cint t7;
  object_Dec_ref(((cptr)function_self)[8] /* name*/);
  object_reclaim((cint)function_self);
  t7_label: return t7;
}

cint function_Apply(cint function_self, cint function_params){
  cint function_result, function_Saved_module, function_Saved_calling_scope, function_rv;
  cint t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40;
  t9 = ((cptr)function_self)[12] /* memo*/ != object_Undefined;
  if (t9){
    ((cptr)((cptr)function_self)[12] /* memo*/)[1] += 1;
    ((cptr)function_params)[1] += 1;
    t10 = ((cptr)(((cptr)((cptr)function_self)[12] /* memo*/)[0]))[9];
    t11 = ((f0)t10)((cint)((cptr)function_self)[12] /* memo*/, (cint)function_params); /* Apply*/
    function_result = t11;
    t13 = function_result != object_Undefined;
    if (t13){
      object_Dec_ref(function_self);
      object_Dec_ref(function_params);
      t8 = function_result;
      goto t8_label;
    };
  };
  t14 = ((cptr)function_self)[10] /* efunc*/ != 0;
  if (t14){
    t15 = function_params != 0;
    if (t15){
      ((cptr)((cptr)function_self)[10] /* efunc*/)[1] += 1;
      t16 = mem_malloc(40); ((cptr)t16)[0] = slist_methods;
      t17 = slist_alloc((cint)t16, (cint)1);
      ((cptr)t17)[1] += 1;
      ((cptr)function_params)[1] += 1;
      t18 = ((cptr)(((cptr)t17)[0]))[7];
      t19 = ((f0)t18)((cint)t17, (cint)function_params); /* Append*/
      t20 = ((cptr)(((cptr)((cptr)function_self)[10] /* efunc*/)[0]))[9];
      t21 = ((f0)t20)((cint)((cptr)function_self)[10] /* efunc*/, (cint)t19); /* Apply*/
      t8 = t21;
      goto t8_label;
    }else{
      ((cptr)((cptr)function_self)[10] /* efunc*/)[1] += 1;
      t24 = ((cptr)(((cptr)((cptr)function_self)[10] /* efunc*/)[0]))[9];
      t25 = ((f0)t24)((cint)((cptr)function_self)[10] /* efunc*/, (cint)0); /* Apply*/
      t8 = t25;
      goto t8_label;
    };
    object_Dec_ref(function_self);
  };
  t27 = debug_get_module();
  function_Saved_module = t27;
  t28 = ((cptr)function_self)[7] /* module*/ != 0;
  if (t28){
    debug_set_module((cint)((cptr)function_self)[7] /* module*/);
  };
  t29 = ((cptr)clib_Trace)[2] /* hashval*/ > 0;
  if (t29){
    stdout_Put_indent();
    t30 = ((cptr)function_self)[7] /* module*/ != 0;
    if (t30){
      cfile_fprintf((cint)clib_stdo, (cint)((cptr)function_self)[7] /* module*/);
    };
    ((cptr)((cptr)function_self)[8] /* name*/)[1] += 1;
    stdout_Put((cint)((cptr)function_self)[8] /* name*/);
    ((cptr)strpool_str_13)[1] += 1;
    stdout_Put((cint)strpool_str_13);
    t31 = ((cptr)clib_Trace)[2] /* hashval*/ > 1;
    if (t31){
      t32 = function_params != 0;
      if (t32){
        ((cptr)function_params)[1] += 1;
        stdout_Put((cint)function_params);
      };
    };
    ((cptr)strpool_str_15)[1] += 1;
    stdout_Put((cint)strpool_str_15);
    stdout_Put_eol();
    stdout_Inc_indent();
  };
  function_Saved_calling_scope = scope_curr;
  function_Calling_scope = function_Saved_calling_scope;
  t33 = mem_malloc(60); ((cptr)t33)[0] = scope_methods;
  t34 = scope_alloc((cint)t33, (cint)((cptr)function_self)[11] /* escope*/, (cint)function_params);
  scope_curr = t34;
  croutine_call((cint)((cptr)function_self)[9] /* body*/);
  ((cptr)scope_curr)[1] += 1;
  ((cptr)strpool_str_85)[1] += 1;
  t35 = ((cptr)(((cptr)scope_curr)[0]))[9];
  t36 = ((f0)t35)((cint)scope_curr, (cint)strpool_str_85); /* Apply*/
  function_rv = t36;
  t38 = function_rv != object_Undefined;
  if (t38){
    function_result = ((cptr)function_rv)[8] /* value*/;
    ((cptr)function_rv)[8] /* value*/ = object_Undefined;
  }else{
    function_result = object_Undefined;
  };
  debug_set_module((cint)function_Saved_module);
  t39 = ((cptr)clib_Trace)[2] /* hashval*/ > 0;
  if (t39){
    stdout_Dec_indent();
  };
  t40 = ((cptr)clib_Trace)[2] /* hashval*/ > 2;
  if (t40){
    stdout_Put_indent();
    ((cptr)function_result)[1] += 1;
    stdout_Put((cint)function_result);
    stdout_Put_eol();
  };
  object_Dec_ref(scope_curr);
  object_Dec_ref(function_rv);
  object_Dec_ref(function_self);
  scope_curr = function_Saved_calling_scope;
  t8 = function_result;
  goto t8_label;
  t8_label: return t8;
}

cint function_Call_with_params(cint function_self, cint function_params){
  cint t41, t42, t43, t44, t45, t46, t47, t48, t49, t50, t51, t52;
  ((cptr)((cptr)function_self)[8] /* name*/)[1] += 1;
  ((cptr)strpool_str_13)[1] += 1;
  t42 = ((cptr)(((cptr)((cptr)function_self)[8] /* name*/)[0]))[97];
  t43 = ((f0)t42)((cint)((cptr)function_self)[8] /* name*/, (cint)strpool_str_13); /* Plus*/
  ((cptr)function_params)[1] += 1;
  t44 = ((cptr)(((cptr)function_params)[0]))[88];
  t45 = ((f0)t44)((cint)function_params); /* Mkstr*/
  t47 = ((cptr)(((cptr)t43)[0]))[97];
  t48 = ((f0)t47)((cint)t43, (cint)t45); /* Plus*/
  ((cptr)strpool_str_15)[1] += 1;
  t51 = ((cptr)(((cptr)t48)[0]))[97];
  t52 = ((f0)t51)((cint)t48, (cint)strpool_str_15); /* Plus*/
  debug_message((cint)t52);
  ((cptr)strpool_str_86)[1] += 1;
  debug_message((cint)strpool_str_86);
  debug_interact();
  t41_label: return t41;
}

cint function_Make_parameter(cint function_self, cint function_ob){
  cint function_result;
  cint t53, t54, t55;
  t54 = mem_malloc(36); ((cptr)t54)[0] = parameter_methods;
  t55 = parameter_alloc((cint)t54, (cint)function_self, (cint)function_ob);
  t53 = t55;
  goto t53_label;
  t53_label: return t53;
}

cint function_Make_parameterless(cint function_self){
  cint function_result;
  cint t56, t57, t58;
  t57 = mem_malloc(36); ((cptr)t57)[0] = parameter_methods;
  t58 = parameter_alloc((cint)t57, (cint)function_self, (cint)0);
  t56 = t58;
  goto t56_label;
  t56_label: return t56;
}

cint function_Mkstr(cint function_self){
  cint function_result;
  cint t59;
  ((cptr)((cptr)function_self)[8] /* name*/)[1] += 1;
  function_result = ((cptr)function_self)[8] /* name*/;
  object_Dec_ref(function_self);
  t59 = function_result;
  goto t59_label;
  t59_label: return t59;
}

void init_function(){
  copy_meth_table(function_methods, object_methods);
  function_methods[0] = 52;
  function_methods[3] = function_alloc;
  function_methods[119] = function_alloc_new;
  function_methods[4] = function_reclaim;
  function_methods[9] = function_Apply;
  function_methods[18] = function_Call_with_params;
  function_methods[77] = function_Make_parameter;
  function_methods[78] = function_Make_parameterless;
  function_methods[88] = function_Mkstr;
}
