#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr boolean_methods[meth_max];
extern cptr collection_methods[meth_max];
extern cptr set_methods[meth_max];
extern cptr string_methods[meth_max];
#include "cint.h"

extern cint boolean_True;
extern cint object_Undefined;
extern cint boolean_False;
extern cint strpool_str_13;
extern cint strpool_str_15;
extern cint strpool_str_54;
extern cint strpool_str_49;


cptr pset_methods[meth_max];

cint pset_alloc(cint pset_self, cint pset_set1, cint pset_set2){
  cint pset_result;
  cint t1, t2, t3, t4, t5, t6, t7;
  t2 = set_alloc((cint)pset_self);
  pset_result = t2;
  ((cptr)pset_self)[5] /* representation*/ = strpool_str_49;
  t3 = ((cptr)pset_set1)[2] /* hashval*/ + ((cptr)pset_set2)[2] /* hashval*/;
  ((cptr)pset_self)[2] /* hashval*/ = t3;
  t4 = ((cptr)pset_set1)[3] /* len*/ + ((cptr)pset_set2)[3] /* len*/;
  ((cptr)pset_self)[3] /* len*/ = t4;
  t5 = ((cptr)pset_set1)[3] /* len*/ < 0;
  t6 = t5;
  if (!t6){    t7 = ((cptr)pset_set2)[3] /* len*/ < 0;
    t6 = t7;
  };
  if (t6){
    ((cptr)pset_self)[3] /* len*/ = -1;
  };
  ((cptr)pset_self)[8] /* subset1*/ = pset_set1;
  ((cptr)pset_self)[9] /* subset2*/ = pset_set2;
  t1 = pset_result;
  goto t1_label;
  t1_label: return t1;
}

cint pset_reclaim(cint pset_self){
  cint t8;
  object_Dec_ref(((cptr)pset_self)[8] /* subset1*/);
  object_Dec_ref(((cptr)pset_self)[9] /* subset2*/);
  set_reclaim((cint)pset_self);
  t8_label: return t8;
}

cint pset_Contains(cint pset_self, cint pset_ob){
  cint pset_result;
  cint t9, t10, t11, t12, t13, t14, t15, t16;
  ((cptr)((cptr)pset_self)[8] /* subset1*/)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t10 = ((cptr)(((cptr)((cptr)pset_self)[8] /* subset1*/)[0]))[20];
  t11 = ((f0)t10)((cint)((cptr)pset_self)[8] /* subset1*/, (cint)pset_ob); /* Contains*/
  pset_result = t11;
  t13 = pset_result == boolean_False;
  if (t13){
    ((cptr)((cptr)pset_self)[9] /* subset2*/)[1] += 1;
    ((cptr)pset_ob)[1] += 1;
    t14 = ((cptr)(((cptr)((cptr)pset_self)[9] /* subset2*/)[0]))[20];
    t15 = ((f0)t14)((cint)((cptr)pset_self)[9] /* subset2*/, (cint)pset_ob); /* Contains*/
    pset_result = t15;
  };
  object_Dec_ref(pset_self);
  object_Dec_ref(pset_ob);
  t9 = pset_result;
  goto t9_label;
  t9_label: return t9;
}

cint pset_equal(cint pset_self, cint pset_ob){
  cint pset_result;
  cint t17, t18, t19, t20, t21, t22, t23, t24;
  ((cptr)pset_self)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t18 = ((cptr)(((cptr)pset_self)[0]))[104];
  t19 = ((f0)t18)((cint)pset_self, (cint)pset_ob); /* Subset*/
  t22 = t19 == boolean_True;
  t23 = t22;
  if (t23){
  ((cptr)pset_ob)[1] += 1;
  ((cptr)pset_self)[1] += 1;
  t20 = ((cptr)(((cptr)pset_ob)[0]))[104];
  t21 = ((f0)t20)((cint)pset_ob, (cint)pset_self); /* Subset*/
    t24 = t21 == boolean_True;
    t23 = t24;
  };
  if (t23){
    t17 = 1;
    goto t17_label;
  }else{
    t17 = 0;
    goto t17_label;
  };
  t17 = pset_result;
  goto t17_label;
  t17_label: return t17;
}

cint pset_Intersect(cint pset_self, cint pset_ob){
  cint pset_result, pset_s1, pset_s2;
  cint t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37;
  ((cptr)((cptr)pset_self)[8] /* subset1*/)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t26 = ((cptr)(((cptr)((cptr)pset_self)[8] /* subset1*/)[0]))[54];
  t27 = ((f0)t26)((cint)((cptr)pset_self)[8] /* subset1*/, (cint)pset_ob); /* Intersect*/
  pset_s1 = t27;
  ((cptr)((cptr)pset_self)[9] /* subset2*/)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t29 = ((cptr)(((cptr)((cptr)pset_self)[9] /* subset2*/)[0]))[54];
  t30 = ((f0)t29)((cint)((cptr)pset_self)[9] /* subset2*/, (cint)pset_ob); /* Intersect*/
  pset_s2 = t30;
  t32 = pset_s1 == object_Undefined;
  t33 = t32;
  if (!t33){    t34 = pset_s2 == object_Undefined;
    t33 = t34;
  };
  if (t33){
    object_Dec_ref(pset_s1);
    object_Dec_ref(pset_s2);
    pset_result = object_Undefined;
  }else{
    t35 = ((cptr)(((cptr)pset_s1)[0]))[97];
    t36 = ((f0)t35)((cint)pset_s1, (cint)pset_s2); /* Plus*/
    pset_result = t36;
  };
  object_Dec_ref(pset_self);
  object_Dec_ref(pset_ob);
  t25 = pset_result;
  goto t25_label;
  t25_label: return t25;
}

cint pset_Max(cint pset_self, cint pset_ob){
  cint pset_result, pset_m1, pset_m2;
  cint t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48, t49, t50;
  ((cptr)((cptr)pset_self)[8] /* subset1*/)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t39 = ((cptr)(((cptr)((cptr)pset_self)[8] /* subset1*/)[0]))[80];
  t40 = ((f0)t39)((cint)((cptr)pset_self)[8] /* subset1*/, (cint)pset_ob); /* Max*/
  pset_m1 = t40;
  ((cptr)((cptr)pset_self)[9] /* subset2*/)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t42 = ((cptr)(((cptr)((cptr)pset_self)[9] /* subset2*/)[0]))[80];
  t43 = ((f0)t42)((cint)((cptr)pset_self)[9] /* subset2*/, (cint)pset_ob); /* Max*/
  pset_m2 = t43;
  t45 = pset_m1 == object_Undefined;
  t46 = t45;
  if (!t46){    t47 = pset_m2 == object_Undefined;
    t46 = t47;
  };
  if (t46){
    object_Dec_ref(pset_m1);
    object_Dec_ref(pset_m2);
    pset_result = object_Undefined;
  }else{
  t48 = ((cptr)(((cptr)pset_m1)[0]))[60];
  t49 = ((f0)t48)((cint)pset_m1, (cint)pset_m2); /* less_than*/
  t50 = t49 == 1;
  if (t50){
    pset_result = pset_m2;
    object_Dec_ref(pset_m1);
  }else{
    pset_result = pset_m1;
    object_Dec_ref(pset_m2);
  };};
  object_Dec_ref(pset_self);
  object_Dec_ref(pset_ob);
  t38 = pset_result;
  goto t38_label;
  t38_label: return t38;
}

cint pset_Min(cint pset_self, cint pset_ob){
  cint pset_result, pset_m1, pset_m2;
  cint t51, t52, t53, t54, t55, t56, t57, t58, t59, t60, t61, t62, t63;
  ((cptr)((cptr)pset_self)[8] /* subset1*/)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t52 = ((cptr)(((cptr)((cptr)pset_self)[8] /* subset1*/)[0]))[82];
  t53 = ((f0)t52)((cint)((cptr)pset_self)[8] /* subset1*/, (cint)pset_ob); /* Min*/
  pset_m1 = t53;
  ((cptr)((cptr)pset_self)[9] /* subset2*/)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t55 = ((cptr)(((cptr)((cptr)pset_self)[9] /* subset2*/)[0]))[82];
  t56 = ((f0)t55)((cint)((cptr)pset_self)[9] /* subset2*/, (cint)pset_ob); /* Min*/
  pset_m2 = t56;
  t58 = pset_m1 == object_Undefined;
  t59 = t58;
  if (!t59){    t60 = pset_m2 == object_Undefined;
    t59 = t60;
  };
  if (t59){
    object_Dec_ref(pset_m1);
    object_Dec_ref(pset_m2);
    pset_result = object_Undefined;
  }else{
  t61 = ((cptr)(((cptr)pset_m2)[0]))[60];
  t62 = ((f0)t61)((cint)pset_m2, (cint)pset_m1); /* less_than*/
  t63 = t62 == 1;
  if (t63){
    pset_result = pset_m2;
    object_Dec_ref(pset_m1);
  }else{
    pset_result = pset_m1;
    object_Dec_ref(pset_m2);
  };};
  object_Dec_ref(pset_self);
  object_Dec_ref(pset_ob);
  t51 = pset_result;
  goto t51_label;
  t51_label: return t51;
}

cint pset_Minus(cint pset_self, cint pset_ob){
  cint pset_result, pset_s1, pset_s2;
  cint t64, t65, t66, t67, t68, t69, t70, t71, t72, t73, t74, t75, t76;
  ((cptr)((cptr)pset_self)[8] /* subset1*/)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t65 = ((cptr)(((cptr)((cptr)pset_self)[8] /* subset1*/)[0]))[83];
  t66 = ((f0)t65)((cint)((cptr)pset_self)[8] /* subset1*/, (cint)pset_ob); /* Minus*/
  pset_s1 = t66;
  ((cptr)((cptr)pset_self)[9] /* subset2*/)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t68 = ((cptr)(((cptr)((cptr)pset_self)[9] /* subset2*/)[0]))[83];
  t69 = ((f0)t68)((cint)((cptr)pset_self)[9] /* subset2*/, (cint)pset_ob); /* Minus*/
  pset_s2 = t69;
  t71 = pset_s1 == object_Undefined;
  t72 = t71;
  if (!t72){    t73 = pset_s2 == object_Undefined;
    t72 = t73;
  };
  if (t72){
    object_Dec_ref(pset_s1);
    object_Dec_ref(pset_s2);
    pset_result = object_Undefined;
  }else{
    t74 = ((cptr)(((cptr)pset_s1)[0]))[97];
    t75 = ((f0)t74)((cint)pset_s1, (cint)pset_s2); /* Plus*/
    pset_result = t75;
  };
  object_Dec_ref(pset_self);
  object_Dec_ref(pset_ob);
  t64 = pset_result;
  goto t64_label;
  t64_label: return t64;
}

cint pset_Mkstr(cint pset_self){
  cint pset_result, pset_s1, pset_s2;
  cint t77, t78, t79, t80, t81, t82, t83, t84, t85, t86, t87, t88, t89, t90, t91, t92, t93, t94, t95;
  ((cptr)((cptr)pset_self)[8] /* subset1*/)[1] += 1;
  t78 = ((cptr)(((cptr)((cptr)pset_self)[8] /* subset1*/)[0]))[88];
  t79 = ((f0)t78)((cint)((cptr)pset_self)[8] /* subset1*/); /* Mkstr*/
  pset_s1 = t79;
  ((cptr)((cptr)pset_self)[9] /* subset2*/)[1] += 1;
  t81 = ((cptr)(((cptr)((cptr)pset_self)[9] /* subset2*/)[0]))[88];
  t82 = ((f0)t81)((cint)((cptr)pset_self)[9] /* subset2*/); /* Mkstr*/
  pset_s2 = t82;
  ((cptr)strpool_str_13)[1] += 1;
  t84 = ((cptr)(((cptr)strpool_str_13)[0]))[97];
  t85 = ((f0)t84)((cint)strpool_str_13, (cint)pset_s1); /* Plus*/
  ((cptr)strpool_str_54)[1] += 1;
  t87 = ((cptr)(((cptr)t85)[0]))[97];
  t88 = ((f0)t87)((cint)t85, (cint)strpool_str_54); /* Plus*/
  t90 = ((cptr)(((cptr)t88)[0]))[97];
  t91 = ((f0)t90)((cint)t88, (cint)pset_s2); /* Plus*/
  ((cptr)strpool_str_15)[1] += 1;
  t93 = ((cptr)(((cptr)t91)[0]))[97];
  t94 = ((f0)t93)((cint)t91, (cint)strpool_str_15); /* Plus*/
  pset_result = t94;
  object_Dec_ref(pset_self);
  t77 = pset_result;
  goto t77_label;
  t77_label: return t77;
}

cint pset_Plus(cint pset_self, cint pset_ob){
  cint pset_result, pset_s1, pset_s2;
  cint t96, t97, t98, t99, t100, t101, t102, t103, t104, t105, t106, t107, t108, t109, t110, t111, t112, t113, t114, t115, t116, t117, t118, t119, t120, t121, t122, t123, t124, t125, t126, t127, t128, t129, t130, t131, t132, t133, t134, t135, t136, t137, t138, t139, t140, t141, t142, t143, t144, t145, t146, t147;
  t97 = ((cptr)pset_self)[3] /* len*/ < 0;
  t98 = t97;
  if (!t98){    t99 = ((cptr)pset_ob)[3] /* len*/ < 0;
    t98 = t99;
  };
  if (t98){
    t100 = mem_malloc(40); ((cptr)t100)[0] = pset_methods;
    t101 = pset_alloc((cint)t100, (cint)pset_self, (cint)pset_ob);
    t96 = t101;
    goto t96_label;
  };
  ((cptr)((cptr)pset_self)[8] /* subset1*/)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t102 = ((cptr)(((cptr)((cptr)pset_self)[8] /* subset1*/)[0]))[54];
  t103 = ((f0)t102)((cint)((cptr)pset_self)[8] /* subset1*/, (cint)pset_ob); /* Intersect*/
  pset_s1 = t103;
  ((cptr)((cptr)pset_self)[9] /* subset2*/)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t105 = ((cptr)(((cptr)((cptr)pset_self)[9] /* subset2*/)[0]))[54];
  t106 = ((f0)t105)((cint)((cptr)pset_self)[9] /* subset2*/, (cint)pset_ob); /* Intersect*/
  pset_s2 = t106;
  t108 = ((cptr)pset_s1)[3] /* len*/ == 0;
  t109 = t108;
  if (t109){
    t110 = ((cptr)pset_s2)[3] /* len*/ == 0;
    t109 = t110;
  };
  t111 = t109;
  if (t111){
    t112 = pset_s1 != object_Undefined;
    t111 = t112;
  };
  t113 = t111;
  if (t113){
    t114 = pset_s2 != object_Undefined;
    t113 = t114;
  };
  if (t113){
    object_Dec_ref(pset_s1);
    object_Dec_ref(pset_s2);
    t115 = mem_malloc(40); ((cptr)t115)[0] = pset_methods;
    t116 = pset_alloc((cint)t115, (cint)pset_self, (cint)pset_ob);
    t96 = t116;
    goto t96_label;
  }else{
  t117 = ((cptr)pset_s1)[3] /* len*/ == 0;
  t118 = t117;
  if (t118){
    t119 = pset_s1 != object_Undefined;
    t118 = t119;
  };
  if (t118){
    t120 = mem_malloc(40); ((cptr)t120)[0] = pset_methods;
    ((cptr)((cptr)pset_self)[8] /* subset1*/)[1] += 1;
    ((cptr)((cptr)pset_self)[9] /* subset2*/)[1] += 1;
    t121 = ((cptr)(((cptr)((cptr)pset_self)[9] /* subset2*/)[0]))[97];
    t122 = ((f0)t121)((cint)((cptr)pset_self)[9] /* subset2*/, (cint)pset_ob); /* Plus*/
    t123 = pset_alloc((cint)t120, (cint)((cptr)pset_self)[8] /* subset1*/, (cint)t122);
    pset_result = t123;
  }else{
  t125 = ((cptr)pset_s2)[3] /* len*/ == 0;
  t126 = t125;
  if (t126){
    t127 = pset_s2 != object_Undefined;
    t126 = t127;
  };
  if (t126){
    t128 = mem_malloc(40); ((cptr)t128)[0] = pset_methods;
    ((cptr)((cptr)pset_self)[8] /* subset1*/)[1] += 1;
    t129 = ((cptr)(((cptr)((cptr)pset_self)[8] /* subset1*/)[0]))[97];
    t130 = ((f0)t129)((cint)((cptr)pset_self)[8] /* subset1*/, (cint)pset_ob); /* Plus*/
    ((cptr)((cptr)pset_self)[9] /* subset2*/)[1] += 1;
    t131 = pset_alloc((cint)t128, (cint)t130, (cint)((cptr)pset_self)[9] /* subset2*/);
    pset_result = t131;
  }else{
    object_Dec_ref(pset_s1);
    object_Dec_ref(pset_s2);
    ((cptr)((cptr)pset_self)[8] /* subset1*/)[1] += 1;
    ((cptr)pset_ob)[1] += 1;
    t133 = ((cptr)(((cptr)((cptr)pset_self)[8] /* subset1*/)[0]))[83];
    t134 = ((f0)t133)((cint)((cptr)pset_self)[8] /* subset1*/, (cint)pset_ob); /* Minus*/
    pset_s1 = t134;
    ((cptr)((cptr)pset_self)[9] /* subset2*/)[1] += 1;
    ((cptr)pset_ob)[1] += 1;
    t136 = ((cptr)(((cptr)((cptr)pset_self)[9] /* subset2*/)[0]))[83];
    t137 = ((f0)t136)((cint)((cptr)pset_self)[9] /* subset2*/, (cint)pset_ob); /* Minus*/
    pset_s2 = t137;
    t139 = pset_s1 == object_Undefined;
    t140 = t139;
    if (!t140){      t141 = pset_s2 == object_Undefined;
      t140 = t141;
    };
    if (t140){
      pset_result = object_Undefined;
    }else{
      object_Dec_ref(pset_self);
      t142 = ((cptr)(((cptr)pset_s1)[0]))[97];
      t143 = ((f0)t142)((cint)pset_s1, (cint)pset_s2); /* Plus*/
      t145 = ((cptr)(((cptr)t143)[0]))[97];
      t146 = ((f0)t145)((cint)t143, (cint)pset_ob); /* Plus*/
      t96 = t146;
      goto t96_label;
    };
  };};};
  object_Dec_ref(pset_self);
  object_Dec_ref(pset_s1);
  object_Dec_ref(pset_s2);
  t96 = pset_result;
  goto t96_label;
  t96_label: return t96;
}

cint pset_Subset(cint pset_self, cint pset_ob){
  cint pset_result;
  cint t148, t149, t150, t151, t152, t153, t154, t155;
  ((cptr)((cptr)pset_self)[8] /* subset1*/)[1] += 1;
  ((cptr)pset_ob)[1] += 1;
  t149 = ((cptr)(((cptr)((cptr)pset_self)[8] /* subset1*/)[0]))[104];
  t150 = ((f0)t149)((cint)((cptr)pset_self)[8] /* subset1*/, (cint)pset_ob); /* Subset*/
  pset_result = t150;
  t152 = pset_result == boolean_True;
  if (t152){
    ((cptr)((cptr)pset_self)[9] /* subset2*/)[1] += 1;
    ((cptr)pset_ob)[1] += 1;
    t153 = ((cptr)(((cptr)((cptr)pset_self)[9] /* subset2*/)[0]))[104];
    t154 = ((f0)t153)((cint)((cptr)pset_self)[9] /* subset2*/, (cint)pset_ob); /* Subset*/
    pset_result = t154;
  };
  object_Dec_ref(pset_self);
  object_Dec_ref(pset_ob);
  t148 = pset_result;
  goto t148_label;
  t148_label: return t148;
}

void init_pset(){
  copy_meth_table(pset_methods, set_methods);
  pset_methods[0] = 40;
  pset_methods[3] = pset_alloc;
  pset_methods[4] = pset_reclaim;
  pset_methods[20] = pset_Contains;
  pset_methods[37] = pset_equal;
  pset_methods[54] = pset_Intersect;
  pset_methods[80] = pset_Max;
  pset_methods[82] = pset_Min;
  pset_methods[83] = pset_Minus;
  pset_methods[88] = pset_Mkstr;
  pset_methods[97] = pset_Plus;
  pset_methods[104] = pset_Subset;
}
