#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr collection_methods[meth_max];
extern cptr boolean_methods[meth_max];
extern cptr string_methods[meth_max];
#include "cint.h"
extern cptr strpool_methods[meth_max];
extern cptr sset_methods[meth_max];
extern cptr slist_methods[meth_max];
extern cptr entset_methods[meth_max];
extern cptr listset_methods[meth_max];
extern cptr powset_methods[meth_max];
extern cptr map_methods[meth_max];
extern cptr pset_methods[meth_max];
extern cptr mset_methods[meth_max];

extern cint boolean_True;
extern cint strpool_str_9;
extern cint object_Undefined;
extern cint entset_predef;
extern cint boolean_False;
extern cint strpool_str_32;
extern cint strpool_str_31;
extern cint strpool_str_50;
extern cint strpool_str_51;
extern cint strpool_str_52;
extern cint strpool_str_49;


cptr set_methods[meth_max];

cint set_alloc(cint set_self){
  cint set_result;
  cint t1, t2;
  t2 = collection_alloc((cint)set_self);
  set_result = t2;
  ((cptr)set_self)[4] /* class_of*/ = strpool_str_32;
  t1 = set_result;
  goto t1_label;
  t1_label: return t1;
}

cint set_reclaim(cint set_self){
  cint t3;
  collection_reclaim((cint)set_self);
  t3_label: return t3;
}

cint set_Append(cint set_self, cint set_item){
  cint set_result;
  cint t4, t5, t6, t7, t8, t9, t10, t11, t12;
  t5 = mem_malloc(48); ((cptr)t5)[0] = sset_methods;
  t6 = sset_alloc((cint)t5);
  t7 = ((cptr)(((cptr)t6)[0]))[7];
  t8 = ((f0)t7)((cint)t6, (cint)set_item); /* Append*/
  t10 = ((cptr)(((cptr)t8)[0]))[97];
  t11 = ((f0)t10)((cint)t8, (cint)set_self); /* Plus*/
  t4 = t11;
  goto t4_label;
  t4_label: return t4;
}

cint set_Apply(cint set_self, cint set_params){
  cint set_result;
  cint t13;
  set_result = object_Undefined;
  object_Dec_ref(set_self);
  object_Dec_ref(set_params);
  t13 = set_result;
  goto t13_label;
  t13_label: return t13;
}

cint set_Delete_ith(cint set_self, cint set_i){
  cint set_result, set_j, set_elem;
  cint t14, t15, t16, t17, t19, t20, t21, t22, t23, t24, t25;
  t15 = ((cptr)set_self)[3] /* len*/ < 1;
  if (t15){
    object_Dec_ref(set_self);
    t14 = object_Undefined;
    goto t14_label;
  };
  t16 = mem_malloc(48); ((cptr)t16)[0] = sset_methods;
  t17 = sset_alloc((cint)t16);
  set_result = t17;
  ((cptr)((cptr)set_self)[7] /* elemtype*/)[1] += 1;
  ((cptr)set_result)[7] /* elemtype*/ = ((cptr)set_self)[7] /* elemtype*/;
  ((cptr)set_result)[6] /* name_space*/ = ((cptr)set_self)[6] /* name_space*/;
  for (set_j = 1; set_j <= ((cptr)set_self)[3] /* len*/; set_j++){
    t19 = set_j != set_i;
    if (t19){
      t20 = ((cptr)(((cptr)set_self)[0]))[62];
      t21 = ((f0)t20)((cint)set_self, (cint)set_j); /* lookup*/
      set_elem = t21;
      ((cptr)set_elem)[1] += 1;
      t23 = ((cptr)(((cptr)set_result)[0]))[7];
      t24 = ((f0)t23)((cint)set_result, (cint)set_elem); /* Append*/
      set_result = t24;
    };
  };t18:;
  object_Dec_ref(set_self);
  t14 = set_result;
  goto t14_label;
  t14_label: return t14;
}

cint set_equal(cint set_self, cint set_ob){
  cint set_result, set_i;
  cint t26, t27, t28, t29, t30, t32, t33, t34, t35, t36, t37;
  t27 = set_self == set_ob;
  if (t27){
    t26 = 1;
    goto t26_label;
  };
  t28 = ((cptr)set_ob)[4] /* class_of*/ != strpool_str_32;
  if (t28){
    t26 = 0;
    goto t26_label;
  };
  t29 = ((cptr)set_self)[3] /* len*/ != ((cptr)set_ob)[3] /* len*/;
  if (t29){
    t26 = 0;
    goto t26_label;
  };
  t30 = ((cptr)set_self)[2] /* hashval*/ != ((cptr)set_ob)[2] /* hashval*/;
  if (t30){
    t26 = 0;
    goto t26_label;
  };
  for (set_i = 1; set_i <= ((cptr)set_self)[3] /* len*/; set_i++){
    ((cptr)set_self)[1] += 1;
    t34 = ((cptr)(((cptr)set_ob)[0]))[62];
    t33 = ((f0)t34)((cint)set_ob, (cint)set_i); /* lookup*/
    ((cptr)t33)[1] += 1;
    t35 = ((cptr)(((cptr)set_self)[0]))[20];
    t36 = ((f0)t35)((cint)set_self, (cint)t33); /* Contains*/
    t37 = t36 == boolean_False;
    if (t37){
      t26 = 0;
      goto t26_label;
    };
  };t31:;
  t26 = 1;
  goto t26_label;
  t26_label: return t26;
}

cint set_Expanded_with(cint set_self, cint set_ob){
  cint set_result;
  cint t38, t39, t40, t41;
  ((cptr)set_self)[1] += 1;
  ((cptr)set_ob)[1] += 1;
  t39 = ((cptr)(((cptr)set_self)[0]))[20];
  t40 = ((f0)t39)((cint)set_self, (cint)set_ob); /* Contains*/
  t41 = t40 == boolean_True;
  if (t41){
    t38 = set_self;
    goto t38_label;
  };
  object_Dec_ref(set_self);
  ((cptr)entset_predef)[1] += 1;
  t38 = entset_predef;
  goto t38_label;
  t38_label: return t38;
}

cint set_Intersect(cint set_self, cint set_ob){
  cint set_result, set_i, set_elem;
  cint t42, t43, t44, t45, t46, t47, t48, t49, t50, t51, t52, t53, t54, t55, t57, t58, t59, t60, t61, t62, t63, t64, t65;
  t43 = ((cptr)set_ob)[5] /* representation*/ == strpool_str_31;
  t44 = t43;
  if (!t44){    t45 = set_self == set_ob;
    t44 = t45;
  };
  if (t44){
    object_Dec_ref(set_ob);
    t42 = set_self;
    goto t42_label;
  }else{
  t46 = ((cptr)set_self)[3] /* len*/ < 0;
  if (t46){
    t47 = ((cptr)set_ob)[5] /* representation*/ == strpool_str_49;
    t48 = t47;
    if (!t48){      t49 = ((cptr)set_ob)[3] /* len*/ >= 0;
      t48 = t49;
    };
    if (t48){
      t50 = ((cptr)(((cptr)set_ob)[0]))[54];
      t51 = ((f0)t50)((cint)set_ob, (cint)set_self); /* Intersect*/
      t42 = t51;
      goto t42_label;
    };
  }else{
  t53 = ((cptr)set_ob)[4] /* class_of*/ != strpool_str_32;
  if (t53){
    object_Dec_ref(set_self);
    object_Dec_ref(set_ob);
    t42 = object_Undefined;
    goto t42_label;
  };};};
  t54 = mem_malloc(48); ((cptr)t54)[0] = sset_methods;
  t55 = sset_alloc((cint)t54);
  set_result = t55;
  for (set_i = 1; set_i <= ((cptr)set_self)[3] /* len*/; set_i++){
    t57 = ((cptr)(((cptr)set_self)[0]))[62];
    t58 = ((f0)t57)((cint)set_self, (cint)set_i); /* lookup*/
    set_elem = t58;
    ((cptr)set_ob)[1] += 1;
    ((cptr)set_elem)[1] += 1;
    t60 = ((cptr)(((cptr)set_ob)[0]))[20];
    t61 = ((f0)t60)((cint)set_ob, (cint)set_elem); /* Contains*/
    t62 = t61 == boolean_True;
    if (t62){
      ((cptr)set_elem)[1] += 1;
      t63 = ((cptr)(((cptr)set_result)[0]))[7];
      t64 = ((f0)t63)((cint)set_result, (cint)set_elem); /* Append*/
      set_result = t64;
    };
  };t56:;
  object_Dec_ref(set_self);
  object_Dec_ref(set_ob);
  t42 = set_result;
  goto t42_label;
  t42_label: return t42;
}

cint set_List_of(cint set_self){
  cint set_result;
  cint t66, t67, t68;
  t67 = mem_malloc(32); ((cptr)t67)[0] = listset_methods;
  t68 = listset_alloc((cint)t67, (cint)set_self);
  t66 = t68;
  goto t66_label;
  t66_label: return t66;
}

cint set_lookup(cint set_self, cint set_i){
  cint set_result;
  cint t69;
  t69 = object_Undefined;
  goto t69_label;
  t69_label: return t69;
}

cint set_Make_set(cint set_self){
  cint set_result;
  cint t70;
  t70 = set_self;
  goto t70_label;
  t70_label: return t70;
}

cint set_Mapped(cint set_self, cint set_ob){
  cint set_result, set_i, set_elem;
  cint t71, t72, t73, t74, t76, t77, t78, t79, t80, t81, t82, t83, t84, t85, t86, t87, t88, t89;
  t72 = ((cptr)set_self)[3] /* len*/ < 0;
  if (t72){
    object_Dec_ref(set_self);
    object_Dec_ref(set_ob);
    t71 = object_Undefined;
    goto t71_label;
  };
  t73 = mem_malloc(48); ((cptr)t73)[0] = sset_methods;
  t74 = sset_alloc((cint)t73);
  set_result = t74;
  for (set_i = 1; set_i <= ((cptr)set_self)[3] /* len*/; set_i++){
    t76 = ((cptr)(((cptr)set_self)[0]))[62];
    t77 = ((f0)t76)((cint)set_self, (cint)set_i); /* lookup*/
    set_elem = t77;
    ((cptr)set_ob)[1] += 1;
    t79 = mem_malloc(40); ((cptr)t79)[0] = slist_methods;
    t80 = slist_alloc((cint)t79, (cint)1);
    ((cptr)t80)[1] += 1;
    ((cptr)set_elem)[1] += 1;
    t81 = ((cptr)(((cptr)t80)[0]))[7];
    t82 = ((f0)t81)((cint)t80, (cint)set_elem); /* Append*/
    t83 = ((cptr)(((cptr)set_ob)[0]))[9];
    t84 = ((f0)t83)((cint)set_ob, (cint)t82); /* Apply*/
    t85 = ((cptr)(((cptr)set_result)[0]))[7];
    t86 = ((f0)t85)((cint)set_result, (cint)t84); /* Append*/
    set_result = t86;
  };t75:;
  object_Dec_ref(set_self);
  object_Dec_ref(set_ob);
  t71 = set_result;
  goto t71_label;
  t71_label: return t71;
}

cint set_Minus(cint set_self, cint set_ob){
  cint set_result, set_i, set_elem;
  cint t90, t91, t92, t93, t94, t95, t96, t97, t98, t99, t100, t102, t103, t104, t105, t106, t107, t108, t109, t110;
  t91 = ((cptr)set_ob)[5] /* representation*/ == strpool_str_31;
  t92 = t91;
  if (!t92){    t93 = set_self == set_ob;
    t92 = t93;
  };
  if (t92){
    object_Dec_ref(set_self);
    object_Dec_ref(set_ob);
    t94 = mem_malloc(48); ((cptr)t94)[0] = sset_methods;
    t95 = sset_alloc((cint)t94);
    t90 = t95;
    goto t90_label;
  }else{
  t96 = ((cptr)set_self)[3] /* len*/ < 0;
  if (t96){
    t97 = mem_malloc(40); ((cptr)t97)[0] = mset_methods;
    t98 = mset_alloc((cint)t97, (cint)set_self, (cint)set_ob);
    t90 = t98;
    goto t90_label;
  };};
  t99 = mem_malloc(48); ((cptr)t99)[0] = sset_methods;
  t100 = sset_alloc((cint)t99);
  set_result = t100;
  ((cptr)((cptr)set_self)[7] /* elemtype*/)[1] += 1;
  ((cptr)set_result)[7] /* elemtype*/ = ((cptr)set_self)[7] /* elemtype*/;
  ((cptr)set_result)[6] /* name_space*/ = ((cptr)set_self)[6] /* name_space*/;
  for (set_i = 1; set_i <= ((cptr)set_self)[3] /* len*/; set_i++){
    t102 = ((cptr)(((cptr)set_self)[0]))[62];
    t103 = ((f0)t102)((cint)set_self, (cint)set_i); /* lookup*/
    set_elem = t103;
    ((cptr)set_ob)[1] += 1;
    ((cptr)set_elem)[1] += 1;
    t105 = ((cptr)(((cptr)set_ob)[0]))[20];
    t106 = ((f0)t105)((cint)set_ob, (cint)set_elem); /* Contains*/
    t107 = t106 == boolean_False;
    if (t107){
      ((cptr)set_elem)[1] += 1;
      t108 = ((cptr)(((cptr)set_result)[0]))[7];
      t109 = ((f0)t108)((cint)set_result, (cint)set_elem); /* Append*/
      set_result = t109;
    };
  };t101:;
  object_Dec_ref(set_self);
  object_Dec_ref(set_ob);
  t90 = set_result;
  goto t90_label;
  t90_label: return t90;
}

cint set_Mkstr(cint set_self){
  cint set_result;
  cint t111, t112, t113, t114, t115, t116, t117, t118, t119, t120, t121, t122;
  t112 = ((cptr)set_self)[3] /* len*/ < 0;
  if (t112){
    object_Dec_ref(set_self);
    ((cptr)strpool_str_9)[1] += 1;
    t111 = strpool_str_9;
    goto t111_label;
  }else{
  t113 = ((cptr)set_self)[3] /* len*/ < 1;
  if (t113){
    object_Dec_ref(set_self);
    ((cptr)strpool_str_50)[1] += 1;
    t111 = strpool_str_50;
    goto t111_label;
  };};
  ((cptr)strpool_str_51)[1] += 1;
  t114 = ((cptr)(((cptr)set_self)[0]))[112];
  t115 = ((f0)t114)((cint)set_self); /* ubstr*/
  t116 = ((cptr)(((cptr)strpool_str_51)[0]))[97];
  t117 = ((f0)t116)((cint)strpool_str_51, (cint)t115); /* Plus*/
  ((cptr)strpool_str_52)[1] += 1;
  t120 = ((cptr)(((cptr)t117)[0]))[97];
  t121 = ((f0)t120)((cint)t117, (cint)strpool_str_52); /* Plus*/
  set_result = t121;
  object_Dec_ref(set_self);
  t111 = set_result;
  goto t111_label;
  t111_label: return t111;
}

cint set_Plus(cint set_self, cint set_ob){
  cint set_result, set_i;
  cint t123, t124, t125, t126, t127, t128, t129, t130, t131, t132, t133, t134, t135, t136, t137, t139, t140, t141, t142, t143, t144, t146, t147, t148, t149, t150, t151;
  t124 = ((cptr)set_ob)[5] /* representation*/ == strpool_str_31;
  t125 = t124;
  if (!t125){    t126 = set_self == set_ob;
    t125 = t126;
  };
  if (t125){
    object_Dec_ref(set_self);
    t123 = set_ob;
    goto t123_label;
  }else{
  t127 = ((cptr)set_ob)[4] /* class_of*/ != strpool_str_32;
  if (t127){
    object_Dec_ref(set_self);
    object_Dec_ref(set_ob);
    t123 = object_Undefined;
    goto t123_label;
  }else{
  t128 = ((cptr)set_ob)[3] /* len*/ == 0;
  if (t128){
    object_Dec_ref(set_ob);
    t123 = set_self;
    goto t123_label;
  }else{
  t129 = ((cptr)set_self)[3] /* len*/ < 0;
  if (t129){
    t130 = mem_malloc(40); ((cptr)t130)[0] = pset_methods;
    t131 = pset_alloc((cint)t130, (cint)set_self, (cint)set_ob);
    t123 = t131;
    goto t123_label;
  }else{
  t132 = ((cptr)set_ob)[3] /* len*/ < 0;
  if (t132){
    t133 = ((cptr)(((cptr)set_ob)[0]))[97];
    t134 = ((f0)t133)((cint)set_ob, (cint)set_self); /* Plus*/
    t123 = t134;
    goto t123_label;
  };};};};};
  t136 = mem_malloc(48); ((cptr)t136)[0] = sset_methods;
  t137 = sset_alloc((cint)t136);
  set_result = t137;
  for (set_i = 1; set_i <= ((cptr)set_self)[3] /* len*/; set_i++){
    t141 = ((cptr)(((cptr)set_self)[0]))[62];
    t140 = ((f0)t141)((cint)set_self, (cint)set_i); /* lookup*/
    ((cptr)t140)[1] += 1;
    t142 = ((cptr)(((cptr)set_result)[0]))[7];
    t143 = ((f0)t142)((cint)set_result, (cint)t140); /* Append*/
    set_result = t143;
  };t138:;
  for (set_i = 1; set_i <= ((cptr)set_ob)[3] /* len*/; set_i++){
    t148 = ((cptr)(((cptr)set_ob)[0]))[62];
    t147 = ((f0)t148)((cint)set_ob, (cint)set_i); /* lookup*/
    ((cptr)t147)[1] += 1;
    t149 = ((cptr)(((cptr)set_result)[0]))[7];
    t150 = ((f0)t149)((cint)set_result, (cint)t147); /* Append*/
    set_result = t150;
  };t145:;
  object_Dec_ref(set_self);
  object_Dec_ref(set_ob);
  t123 = set_result;
  goto t123_label;
  t123_label: return t123;
}

cint set_Powerset(cint set_self){
  cint set_result;
  cint t152, t153, t154;
  t153 = mem_malloc(32); ((cptr)t153)[0] = powset_methods;
  t154 = powset_alloc((cint)t153, (cint)set_self);
  t152 = t154;
  goto t152_label;
  t152_label: return t152;
}

void init_set(){
  copy_meth_table(set_methods, collection_methods);
  set_methods[0] = 32;
  set_methods[3] = set_alloc;
  set_methods[4] = set_reclaim;
  set_methods[7] = set_Append;
  set_methods[9] = set_Apply;
  set_methods[29] = set_Delete_ith;
  set_methods[37] = set_equal;
  set_methods[41] = set_Expanded_with;
  set_methods[54] = set_Intersect;
  set_methods[61] = set_List_of;
  set_methods[62] = set_lookup;
  set_methods[74] = set_Make_set;
  set_methods[79] = set_Mapped;
  set_methods[83] = set_Minus;
  set_methods[88] = set_Mkstr;
  set_methods[97] = set_Plus;
  set_methods[99] = set_Powerset;
}
