#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 cptr pset_methods[meth_max];

extern cint boolean_True;
extern cint object_Undefined;
extern cint boolean_False;
extern cint strpool_str_150;
extern cint strpool_str_170;
extern cint strpool_str_13;
extern cint strpool_str_32;
extern cint strpool_str_15;
extern cint strpool_str_49;


cptr mset_methods[meth_max];

cint mset_alloc(cint mset_self, cint mset_set1, cint mset_set2){
  cint mset_result;
  cint t1, t2, t3;
  t2 = set_alloc((cint)mset_self);
  mset_result = t2;
  ((cptr)mset_self)[5] /* representation*/ = strpool_str_170;
  t3 = ((cptr)mset_set1)[2] /* hashval*/ - ((cptr)mset_set2)[2] /* hashval*/;
  ((cptr)mset_self)[2] /* hashval*/ = t3;
  ((cptr)mset_self)[3] /* len*/ = -1;
  ((cptr)mset_self)[8] /* subset1*/ = mset_set1;
  ((cptr)mset_self)[9] /* subset2*/ = mset_set2;
  t1 = mset_result;
  goto t1_label;
  t1_label: return t1;
}

cint mset_reclaim(cint mset_self){
  cint t4;
  object_Dec_ref(((cptr)mset_self)[8] /* subset1*/);
  object_Dec_ref(((cptr)mset_self)[9] /* subset2*/);
  set_reclaim((cint)mset_self);
  t4_label: return t4;
}

cint mset_Contains(cint mset_self, cint mset_ob){
  cint mset_result;
  cint t5, t6, t7, t8, t9, t10, t11, t12;
  ((cptr)((cptr)mset_self)[9] /* subset2*/)[1] += 1;
  ((cptr)mset_ob)[1] += 1;
  t6 = ((cptr)(((cptr)((cptr)mset_self)[9] /* subset2*/)[0]))[20];
  t7 = ((f0)t6)((cint)((cptr)mset_self)[9] /* subset2*/, (cint)mset_ob); /* Contains*/
  mset_result = t7;
  t9 = mset_result == boolean_True;
  if (t9){
    mset_result = boolean_False;
  }else{
    ((cptr)((cptr)mset_self)[8] /* subset1*/)[1] += 1;
    ((cptr)mset_ob)[1] += 1;
    t10 = ((cptr)(((cptr)((cptr)mset_self)[8] /* subset1*/)[0]))[20];
    t11 = ((f0)t10)((cint)((cptr)mset_self)[8] /* subset1*/, (cint)mset_ob); /* Contains*/
    mset_result = t11;
  };
  object_Dec_ref(mset_self);
  object_Dec_ref(mset_ob);
  t5 = mset_result;
  goto t5_label;
  t5_label: return t5;
}

cint mset_equal(cint mset_self, cint mset_ob){
  cint mset_result;
  cint t13, t14, t15, t16, t17, t18, t19, t20;
  ((cptr)mset_self)[1] += 1;
  ((cptr)mset_ob)[1] += 1;
  t14 = ((cptr)(((cptr)mset_self)[0]))[104];
  t15 = ((f0)t14)((cint)mset_self, (cint)mset_ob); /* Subset*/
  t18 = t15 == boolean_True;
  t19 = t18;
  if (t19){
  ((cptr)mset_ob)[1] += 1;
  ((cptr)mset_self)[1] += 1;
  t16 = ((cptr)(((cptr)mset_ob)[0]))[104];
  t17 = ((f0)t16)((cint)mset_ob, (cint)mset_self); /* Subset*/
    t20 = t17 == boolean_True;
    t19 = t20;
  };
  if (t19){
    t13 = 1;
    goto t13_label;
  }else{
    t13 = 0;
    goto t13_label;
  };
  t13 = mset_result;
  goto t13_label;
  t13_label: return t13;
}

cint mset_Intersect(cint mset_self, cint mset_ob){
  cint mset_result, mset_s1, mset_s2;
  cint t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33;
  ((cptr)((cptr)mset_self)[8] /* subset1*/)[1] += 1;
  ((cptr)mset_ob)[1] += 1;
  t22 = ((cptr)(((cptr)((cptr)mset_self)[8] /* subset1*/)[0]))[54];
  t23 = ((f0)t22)((cint)((cptr)mset_self)[8] /* subset1*/, (cint)mset_ob); /* Intersect*/
  mset_s1 = t23;
  ((cptr)((cptr)mset_self)[9] /* subset2*/)[1] += 1;
  ((cptr)mset_ob)[1] += 1;
  t25 = ((cptr)(((cptr)((cptr)mset_self)[9] /* subset2*/)[0]))[54];
  t26 = ((f0)t25)((cint)((cptr)mset_self)[9] /* subset2*/, (cint)mset_ob); /* Intersect*/
  mset_s2 = t26;
  t28 = mset_s1 == object_Undefined;
  t29 = t28;
  if (!t29){    t30 = mset_s2 == object_Undefined;
    t29 = t30;
  };
  if (t29){
    object_Dec_ref(mset_s1);
    object_Dec_ref(mset_s2);
    mset_result = object_Undefined;
  }else{
    t31 = ((cptr)(((cptr)mset_s1)[0]))[83];
    t32 = ((f0)t31)((cint)mset_s1, (cint)mset_s2); /* Minus*/
    mset_result = t32;
  };
  object_Dec_ref(mset_self);
  object_Dec_ref(mset_ob);
  t21 = mset_result;
  goto t21_label;
  t21_label: return t21;
}

cint mset_Minus(cint mset_self, cint mset_ob){
  cint mset_result, mset_s2;
  cint t34, t35, t36, t37, t38, t39, t40;
  ((cptr)((cptr)mset_self)[9] /* subset2*/)[1] += 1;
  ((cptr)mset_ob)[1] += 1;
  t35 = ((cptr)(((cptr)((cptr)mset_self)[9] /* subset2*/)[0]))[97];
  t36 = ((f0)t35)((cint)((cptr)mset_self)[9] /* subset2*/, (cint)mset_ob); /* Plus*/
  mset_s2 = t36;
  t38 = mset_s2 == object_Undefined;
  if (t38){
    object_Dec_ref(mset_s2);
    mset_result = object_Undefined;
  }else{
    t39 = mem_malloc(40); ((cptr)t39)[0] = mset_methods;
    ((cptr)((cptr)mset_self)[8] /* subset1*/)[1] += 1;
    t40 = mset_alloc((cint)t39, (cint)((cptr)mset_self)[8] /* subset1*/, (cint)mset_s2);
    mset_result = t40;
  };
  object_Dec_ref(mset_self);
  object_Dec_ref(mset_ob);
  t34 = mset_result;
  goto t34_label;
  t34_label: return t34;
}

cint mset_Mkstr(cint mset_self){
  cint mset_result, mset_s1, mset_s2;
  cint t41, t42, t43, t44, t45, t46, t47, t48, t49, t50, t51, t52, t53, t54, t55, t56, t57, t58, t59;
  ((cptr)((cptr)mset_self)[8] /* subset1*/)[1] += 1;
  t42 = ((cptr)(((cptr)((cptr)mset_self)[8] /* subset1*/)[0]))[88];
  t43 = ((f0)t42)((cint)((cptr)mset_self)[8] /* subset1*/); /* Mkstr*/
  mset_s1 = t43;
  ((cptr)((cptr)mset_self)[9] /* subset2*/)[1] += 1;
  t45 = ((cptr)(((cptr)((cptr)mset_self)[9] /* subset2*/)[0]))[88];
  t46 = ((f0)t45)((cint)((cptr)mset_self)[9] /* subset2*/); /* Mkstr*/
  mset_s2 = t46;
  ((cptr)strpool_str_13)[1] += 1;
  t48 = ((cptr)(((cptr)strpool_str_13)[0]))[97];
  t49 = ((f0)t48)((cint)strpool_str_13, (cint)mset_s1); /* Plus*/
  ((cptr)strpool_str_150)[1] += 1;
  t51 = ((cptr)(((cptr)t49)[0]))[97];
  t52 = ((f0)t51)((cint)t49, (cint)strpool_str_150); /* Plus*/
  t54 = ((cptr)(((cptr)t52)[0]))[97];
  t55 = ((f0)t54)((cint)t52, (cint)mset_s2); /* Plus*/
  ((cptr)strpool_str_15)[1] += 1;
  t57 = ((cptr)(((cptr)t55)[0]))[97];
  t58 = ((f0)t57)((cint)t55, (cint)strpool_str_15); /* Plus*/
  mset_result = t58;
  object_Dec_ref(mset_self);
  t41 = mset_result;
  goto t41_label;
  t41_label: return t41;
}

cint mset_Plus(cint mset_self, cint mset_ob){
  cint mset_result;
  cint t60, t61, t62, t63;
  t61 = ((cptr)mset_ob)[4] /* class_of*/ == strpool_str_32;
  if (t61){
    t62 = mem_malloc(40); ((cptr)t62)[0] = pset_methods;
    t63 = pset_alloc((cint)t62, (cint)mset_self, (cint)mset_ob);
    t60 = t63;
    goto t60_label;
  };
  object_Dec_ref(mset_self);
  object_Dec_ref(mset_ob);
  t60 = mset_result;
  goto t60_label;
  t60_label: return t60;
}

cint mset_Subset(cint mset_self, cint mset_ob){
  cint mset_result, mset_m_ob, mset_p_ob;
  cint t64, t65, t66, t67, t68, t69, t70, t71, t72, t73, t74, t75, t76, t77, t78, t79, t80, t81, t82, t83, t84, t85, t86;
  ((cptr)((cptr)mset_self)[8] /* subset1*/)[1] += 1;
  ((cptr)mset_ob)[1] += 1;
  t65 = ((cptr)(((cptr)((cptr)mset_self)[8] /* subset1*/)[0]))[104];
  t66 = ((f0)t65)((cint)((cptr)mset_self)[8] /* subset1*/, (cint)mset_ob); /* Subset*/
  mset_result = t66;
  t68 = mset_result == boolean_False;
  if (t68){
    t69 = ((cptr)mset_ob)[5] /* representation*/ == strpool_str_170;
    if (t69){
      mset_m_ob = mset_ob;
      ((cptr)((cptr)mset_self)[8] /* subset1*/)[1] += 1;
      ((cptr)((cptr)mset_m_ob)[8] /* subset1*/)[1] += 1;
      t70 = ((cptr)(((cptr)((cptr)mset_self)[8] /* subset1*/)[0]))[104];
      t71 = ((f0)t70)((cint)((cptr)mset_self)[8] /* subset1*/, (cint)((cptr)mset_m_ob)[8] /* subset1*/); /* Subset*/
      mset_result = t71;
      t73 = mset_result == boolean_True;
      if (t73){
        ((cptr)((cptr)mset_m_ob)[9] /* subset2*/)[1] += 1;
        ((cptr)((cptr)mset_self)[9] /* subset2*/)[1] += 1;
        t74 = ((cptr)(((cptr)((cptr)mset_m_ob)[9] /* subset2*/)[0]))[104];
        t75 = ((f0)t74)((cint)((cptr)mset_m_ob)[9] /* subset2*/, (cint)((cptr)mset_self)[9] /* subset2*/); /* Subset*/
        mset_result = t75;
        t77 = mset_result == boolean_False;
        if (t77){
          mset_result = object_Undefined;
        };
      }else{
        mset_result = object_Undefined;
      };
    }else{
    t78 = ((cptr)mset_ob)[5] /* representation*/ == strpool_str_49;
    if (t78){
      mset_p_ob = mset_ob;
      ((cptr)mset_self)[1] += 1;
      ((cptr)((cptr)mset_p_ob)[8] /* subset1*/)[1] += 1;
      t79 = ((cptr)(((cptr)mset_self)[0]))[104];
      t80 = ((f0)t79)((cint)mset_self, (cint)((cptr)mset_p_ob)[8] /* subset1*/); /* Subset*/
      mset_result = t80;
      t82 = mset_result == boolean_False;
      if (t82){
        ((cptr)mset_self)[1] += 1;
        ((cptr)((cptr)mset_p_ob)[9] /* subset2*/)[1] += 1;
        t83 = ((cptr)(((cptr)mset_self)[0]))[104];
        t84 = ((f0)t83)((cint)mset_self, (cint)((cptr)mset_p_ob)[9] /* subset2*/); /* Subset*/
        mset_result = t84;
        t86 = mset_result == boolean_False;
        if (t86){
          mset_result = object_Undefined;
        };
      };
    }else{
      mset_result = object_Undefined;
    };};
  };
  object_Dec_ref(mset_self);
  object_Dec_ref(mset_ob);
  t64 = mset_result;
  goto t64_label;
  t64_label: return t64;
}

void init_mset(){
  copy_meth_table(mset_methods, set_methods);
  mset_methods[0] = 40;
  mset_methods[3] = mset_alloc;
  mset_methods[4] = mset_reclaim;
  mset_methods[20] = mset_Contains;
  mset_methods[37] = mset_equal;
  mset_methods[54] = mset_Intersect;
  mset_methods[83] = mset_Minus;
  mset_methods[88] = mset_Mkstr;
  mset_methods[97] = mset_Plus;
  mset_methods[104] = mset_Subset;
}
