#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr set_methods[meth_max];
extern cptr list_methods[meth_max];
extern cptr slist_methods[meth_max];
extern cptr map_methods[meth_max];
extern cptr boolean_methods[meth_max];
#include "cint.h"
extern cptr strpool_methods[meth_max];

extern cint boolean_True;
extern cint object_Undefined;
extern cint boolean_False;
extern cint strpool_str_13;
extern cint strpool_str_14;
extern cint strpool_str_60;
extern cint strpool_str_61;
extern cint strpool_str_62;
extern cint strpool_str_15;
extern cint strpool_str_59;


cptr mapset_methods[meth_max];

cint mapset_alloc(cint mapset_self){
  cint mapset_result;
  cint t1, t2, t3, t4;
  t2 = set_alloc((cint)mapset_self);
  mapset_result = t2;
  ((cptr)mapset_self)[5] /* representation*/ = strpool_str_59;
  t3 = mem_malloc(40); ((cptr)t3)[0] = slist_methods;
  t4 = slist_alloc((cint)t3, (cint)3);
  ((cptr)mapset_self)[8] /* domains*/ = t4;
  ((cptr)mapset_self)[9] /* codomain*/ = 0;
  ((cptr)mapset_self)[3] /* len*/ = -1;
  t1 = mapset_result;
  goto t1_label;
  t1_label: return t1;
}

cint mapset_alloc_new(){
  cint mapset_result;
  cint t5, t6, t7;
  t6 = mem_malloc(40); ((cptr)t6)[0] = mapset_methods;
  t7 = mapset_alloc((cint)t6);
  t5 = t7;
  goto t5_label;
  t5_label: return t5;
}

cint mapset_reclaim(cint mapset_self){
  cint t8;
  object_Dec_ref(((cptr)mapset_self)[8] /* domains*/);
  object_Dec_ref(((cptr)mapset_self)[9] /* codomain*/);
  set_reclaim((cint)mapset_self);
  t8_label: return t8;
}

cint mapset_Contains(cint mapset_self, cint mapset_ob){
  cint mapset_result, mapset_m, mapset_i, mapset_sd, mapset_md;
  cint t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39;
  mapset_result = boolean_False;
  t10 = ((cptr)mapset_ob)[4] /* class_of*/ == strpool_str_60;
  if (t10){
    mapset_m = mapset_ob;
    t11 = ((cptr)((cptr)mapset_self)[8] /* domains*/)[3] /* len*/ == ((cptr)((cptr)mapset_m)[7] /* domains*/)[3] /* len*/;
    if (t11){
      ((cptr)((cptr)mapset_m)[8] /* codomain*/)[1] += 1;
      t12 = ((cptr)(((cptr)((cptr)mapset_m)[8] /* codomain*/)[0]))[38];
      t13 = ((f0)t12)((cint)((cptr)mapset_m)[8] /* codomain*/); /* Eval*/
      ((cptr)((cptr)mapset_self)[9] /* codomain*/)[1] += 1;
      t14 = ((cptr)(((cptr)((cptr)mapset_self)[9] /* codomain*/)[0]))[38];
      t15 = ((f0)t14)((cint)((cptr)mapset_self)[9] /* codomain*/); /* Eval*/
      t17 = ((cptr)(((cptr)t13)[0]))[104];
      t18 = ((f0)t17)((cint)t13, (cint)t15); /* Subset*/
      mapset_result = t18;
      for (mapset_i = 1; mapset_i <= ((cptr)((cptr)mapset_self)[8] /* domains*/)[3] /* len*/; mapset_i++){
        t22 = mapset_result == boolean_False;
        if (t22){
          goto t21;
        };
        t25 = ((cptr)(((cptr)((cptr)mapset_self)[8] /* domains*/)[0]))[62];
        t24 = ((f0)t25)((cint)((cptr)mapset_self)[8] /* domains*/, (cint)mapset_i); /* lookup*/
        ((cptr)t24)[1] += 1;
        mapset_sd = t24;
        t28 = ((cptr)(((cptr)((cptr)mapset_m)[7] /* domains*/)[0]))[62];
        t27 = ((f0)t28)((cint)((cptr)mapset_m)[7] /* domains*/, (cint)mapset_i); /* lookup*/
        ((cptr)t27)[1] += 1;
        mapset_md = t27;
        t29 = ((cptr)(((cptr)mapset_md)[0]))[38];
        t30 = ((f0)t29)((cint)mapset_md); /* Eval*/
        t31 = ((cptr)(((cptr)mapset_sd)[0]))[38];
        t32 = ((f0)t31)((cint)mapset_sd); /* Eval*/
        t34 = ((cptr)(((cptr)t30)[0]))[104];
        t35 = ((f0)t34)((cint)t30, (cint)t32); /* Subset*/
        mapset_result = t35;
      };t21:;
    };
    t38 = mapset_result == boolean_True;
    if (t38){
      object_Dec_ref(((cptr)mapset_m)[7] /* domains*/);
      object_Dec_ref(((cptr)mapset_m)[8] /* codomain*/);
      ((cptr)((cptr)mapset_self)[8] /* domains*/)[1] += 1;
      ((cptr)mapset_m)[7] /* domains*/ = ((cptr)mapset_self)[8] /* domains*/;
      ((cptr)((cptr)mapset_self)[9] /* codomain*/)[1] += 1;
      ((cptr)mapset_m)[8] /* codomain*/ = ((cptr)mapset_self)[9] /* codomain*/;
    };
  }else{
  t39 = mapset_ob == object_Undefined;
  if (t39){
    mapset_result = boolean_True;
  };};
  object_Dec_ref(mapset_self);
  object_Dec_ref(mapset_ob);
  t9 = mapset_result;
  goto t9_label;
  t9_label: return t9;
}

cint mapset_Codomain(cint mapset_self, cint mapset_codom){
  cint mapset_result;
  cint t40;
  ((cptr)mapset_self)[9] /* codomain*/ = mapset_codom;
  t40 = mapset_self;
  goto t40_label;
  t40_label: return t40;
}

cint mapset_Domain(cint mapset_self, cint mapset_dom){
  cint mapset_result;
  cint t41, t42, t43, t44;
  t42 = ((cptr)(((cptr)((cptr)mapset_self)[8] /* domains*/)[0]))[7];
  t43 = ((f0)t42)((cint)((cptr)mapset_self)[8] /* domains*/, (cint)mapset_dom); /* Append*/
  ((cptr)mapset_self)[8] /* domains*/ = t43;
  t41 = mapset_self;
  goto t41_label;
  t41_label: return t41;
}

cint mapset_map_for(cint mapset_self){
  cint mapset_result;
  cint t45, t46, t47;
  t46 = mem_malloc(48); ((cptr)t46)[0] = map_methods;
  t47 = map_alloc((cint)t46);
  mapset_result = t47;
  ((cptr)((cptr)mapset_self)[8] /* domains*/)[1] += 1;
  ((cptr)mapset_result)[7] /* domains*/ = ((cptr)mapset_self)[8] /* domains*/;
  ((cptr)((cptr)mapset_self)[9] /* codomain*/)[1] += 1;
  ((cptr)mapset_result)[8] /* codomain*/ = ((cptr)mapset_self)[9] /* codomain*/;
  t45 = mapset_result;
  goto t45_label;
  t45_label: return t45;
}

cint mapset_Mkstr(cint mapset_self){
  cint mapset_result, mapset_i, mapset_dom;
  cint t48, t49, t50, t51, t52, t54, t55, t56, t57, t58, t59, t60, t61, t62, t63, t64, t65, t66, t67, t68, t69, t70, t71, t72, t73, t74, t75, t76, t77, t78, t79, t80, t81, t82, t83, t84, t85, t86, t87, t88, t89, t90, t91, t92, t93, t94, t95, t96;
  t49 = ((cptr)mapset_self)[9] /* codomain*/ == 0;
  if (t49){
    ((cptr)mapset_self)[9] /* codomain*/ = object_Undefined;
  };
  ((cptr)strpool_str_13)[1] += 1;
  ((cptr)strpool_str_61)[1] += 1;
  t50 = ((cptr)(((cptr)strpool_str_13)[0]))[97];
  t51 = ((f0)t50)((cint)strpool_str_13, (cint)strpool_str_61); /* Plus*/
  mapset_result = t51;
  t54 = ((cptr)((cptr)mapset_self)[8] /* domains*/)[3] /* len*/ - 1;
  for (mapset_i = 1; mapset_i <= t54; mapset_i++){
    t57 = ((cptr)(((cptr)((cptr)mapset_self)[8] /* domains*/)[0]))[62];
    t56 = ((f0)t57)((cint)((cptr)mapset_self)[8] /* domains*/, (cint)mapset_i); /* lookup*/
    ((cptr)t56)[1] += 1;
    mapset_dom = t56;
    t58 = ((cptr)(((cptr)mapset_dom)[0]))[38];
    t59 = ((f0)t58)((cint)mapset_dom); /* Eval*/
    t61 = ((cptr)(((cptr)t59)[0]))[88];
    t62 = ((f0)t61)((cint)t59); /* Mkstr*/
    t63 = ((cptr)(((cptr)mapset_result)[0]))[97];
    t64 = ((f0)t63)((cint)mapset_result, (cint)t62); /* Plus*/
    ((cptr)strpool_str_14)[1] += 1;
    t67 = ((cptr)(((cptr)t64)[0]))[97];
    t68 = ((f0)t67)((cint)t64, (cint)strpool_str_14); /* Plus*/
    mapset_result = t68;
  };t53:;
  t72 = ((cptr)(((cptr)((cptr)mapset_self)[8] /* domains*/)[0]))[62];
  t71 = ((f0)t72)((cint)((cptr)mapset_self)[8] /* domains*/, (cint)((cptr)((cptr)mapset_self)[8] /* domains*/)[3] /* len*/); /* lookup*/
  ((cptr)t71)[1] += 1;
  mapset_dom = t71;
  t73 = ((cptr)(((cptr)mapset_dom)[0]))[38];
  t74 = ((f0)t73)((cint)mapset_dom); /* Eval*/
  t76 = ((cptr)(((cptr)t74)[0]))[88];
  t77 = ((f0)t76)((cint)t74); /* Mkstr*/
  t78 = ((cptr)(((cptr)mapset_result)[0]))[97];
  t79 = ((f0)t78)((cint)mapset_result, (cint)t77); /* Plus*/
  ((cptr)strpool_str_62)[1] += 1;
  t82 = ((cptr)(((cptr)t79)[0]))[97];
  t83 = ((f0)t82)((cint)t79, (cint)strpool_str_62); /* Plus*/
  ((cptr)((cptr)mapset_self)[9] /* codomain*/)[1] += 1;
  t84 = ((cptr)(((cptr)((cptr)mapset_self)[9] /* codomain*/)[0]))[38];
  t85 = ((f0)t84)((cint)((cptr)mapset_self)[9] /* codomain*/); /* Eval*/
  t87 = ((cptr)(((cptr)t85)[0]))[88];
  t88 = ((f0)t87)((cint)t85); /* Mkstr*/
  t90 = ((cptr)(((cptr)t83)[0]))[97];
  t91 = ((f0)t90)((cint)t83, (cint)t88); /* Plus*/
  ((cptr)strpool_str_15)[1] += 1;
  t94 = ((cptr)(((cptr)t91)[0]))[97];
  t95 = ((f0)t94)((cint)t91, (cint)strpool_str_15); /* Plus*/
  mapset_result = t95;
  object_Dec_ref(mapset_self);
  t48 = mapset_result;
  goto t48_label;
  t48_label: return t48;
}

void init_mapset(){
  copy_meth_table(mapset_methods, set_methods);
  mapset_methods[0] = 40;
  mapset_methods[3] = mapset_alloc;
  mapset_methods[119] = mapset_alloc_new;
  mapset_methods[4] = mapset_reclaim;
  mapset_methods[20] = mapset_Contains;
  mapset_methods[19] = mapset_Codomain;
  mapset_methods[34] = mapset_Domain;
  mapset_methods[193] = mapset_map_for;
  mapset_methods[88] = mapset_Mkstr;
}
