#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr set_methods[meth_max];
extern cptr sset_methods[meth_max];
extern cptr rset_methods[meth_max];
extern cptr boolean_methods[meth_max];
extern cptr collection_methods[meth_max];
extern cptr string_methods[meth_max];
extern cptr strpool_methods[meth_max];
extern cptr integer_methods[meth_max];
#include "cint.h"
extern cptr entset_methods[meth_max];
extern cptr numset_methods[meth_max];
#include "cfloat.h"
extern cptr float_methods[meth_max];
extern cptr pset_methods[meth_max];

extern cint strpool_str_5;
extern cint boolean_True;
extern cint entset_predef;
extern cint boolean_False;
extern cint numset_predef;
extern cint strpool_str_159;
extern cint strpool_str_12;
extern cint strpool_str_31;
extern cint strpool_str_13;
extern cint strpool_str_15;
extern cint strpool_str_32;
extern cint strpool_str_19;
extern cint strpool_str_56;
extern cint strpool_str_49;

cint intset_predef;

cptr intset_methods[meth_max];

cint intset_init(){
  cint t1, t2, t3;
  t2 = mem_malloc(44); ((cptr)t2)[0] = intset_methods;
  intset_predef = t2;
  t3 = intset_alloc((cint)intset_predef);
  intset_predef = t3;
  t1_label: return t1;
}

cint intset_fini(){
  cint t4;
  object_Dec_ref(intset_predef);
  t4_label: return t4;
}

cint intset_alloc(cint intset_self){
  cint intset_result, intset_mini, intset_maxi;
  cint t5, t6, t7, t8, t9, t10;
  t6 = mem_malloc(28); ((cptr)t6)[0] = integer_methods;
  t7 = integer_ialloc((cint)t6, (cint)minint);
  intset_mini = t7;
  t8 = mem_malloc(28); ((cptr)t8)[0] = integer_methods;
  t9 = integer_ialloc((cint)t8, (cint)maxint);
  intset_maxi = t9;
  t10 = rset_alloc((cint)intset_self, (cint)intset_mini, (cint)intset_maxi);
  intset_result = t10;
  ((cptr)intset_result)[3] /* len*/ = -1;
  ((cptr)intset_result)[1] += 1;
  ((cptr)intset_result)[7] /* elemtype*/ = intset_result;
  t5 = intset_result;
  goto t5_label;
  t5_label: return t5;
}

cint intset_reclaim(cint intset_self){
  cint t11;
  rset_reclaim((cint)intset_self);
  t11_label: return t11;
}

cint intset_Contains(cint intset_self, cint intset_ob){
  cint intset_result, intset_f;
  cint t12, t13, t14, t15;
  intset_result = boolean_False;
  t13 = ((cptr)intset_ob)[4] /* class_of*/ == strpool_str_5;
  if (t13){
    intset_result = boolean_True;
  };
  t14 = ((cptr)intset_ob)[4] /* class_of*/ == strpool_str_19;
  if (t14){
    intset_f = intset_ob;
    t15 = cfloat_f_ceil((cint)((cptr)intset_f)[7] /* fval*/) == cfloat_f_floor((cint)((cptr)intset_f)[7] /* fval*/);
    if (t15){
      intset_result = boolean_True;
    };
  };
  object_Dec_ref(intset_self);
  object_Dec_ref(intset_ob);
  t12 = intset_result;
  goto t12_label;
  t12_label: return t12;
}

cint intset_equal(cint intset_self, cint intset_ob){
  cint intset_result;
  cint t16, t17;
  t17 = intset_self == intset_ob;
  if (t17){
    t16 = 1;
    goto t16_label;
  };
  t16 = 0;
  goto t16_label;
  t16_label: return t16;
}

cint intset_Expanded_with(cint intset_self, cint intset_ob){
  cint intset_result, intset_f;
  cint t18, t19, t20, t21, t22;
  t19 = ((cptr)intset_ob)[4] /* class_of*/ == strpool_str_5;
  if (t19){
    t18 = intset_self;
    goto t18_label;
  };
  t20 = ((cptr)intset_ob)[4] /* class_of*/ == strpool_str_19;
  if (t20){
    intset_f = intset_ob;
    t21 = cfloat_f_ceil((cint)((cptr)intset_f)[7] /* fval*/) == cfloat_f_floor((cint)((cptr)intset_f)[7] /* fval*/);
    if (t21){
      t18 = intset_self;
      goto t18_label;
    };
    object_Dec_ref(intset_self);
    t22 = ((cptr)intset_ob)[4] /* class_of*/ == strpool_str_19;
    if (t22){
      ((cptr)numset_predef)[1] += 1;
      t18 = numset_predef;
      goto t18_label;
    };
  };
  object_Dec_ref(intset_self);
  ((cptr)entset_predef)[1] += 1;
  t18 = entset_predef;
  goto t18_label;
  t18_label: return t18;
}

cint intset_Intersect(cint intset_self, cint intset_ob){
  cint intset_result;
  cint t23, t24, t25, t26, t27, t28, t29;
  t24 = ((cptr)intset_ob)[5] /* representation*/ == strpool_str_56;
  t25 = t24;
  if (!t25){    t26 = ((cptr)intset_ob)[5] /* representation*/ == strpool_str_31;
    t25 = t26;
  };
  t27 = t25;
  if (!t27){    t28 = intset_self == intset_ob;
    t27 = t28;
  };
  if (t27){
    object_Dec_ref(intset_ob);
    t23 = intset_self;
    goto t23_label;
  }else{
    t29 = rset_Intersect((cint)intset_self, (cint)intset_ob);
    t23 = t29;
    goto t23_label;
  };
  t23 = intset_result;
  goto t23_label;
  t23_label: return t23;
}

cint intset_Minus(cint intset_self, cint intset_ob){
  cint intset_result;
  cint t30, t31, t32, t33, t34, t35, t36, t37, t38;
  t31 = ((cptr)intset_ob)[5] /* representation*/ == strpool_str_31;
  t32 = t31;
  if (!t32){    t33 = ((cptr)intset_ob)[5] /* representation*/ == strpool_str_56;
    t32 = t33;
  };
  t34 = t32;
  if (!t34){    t35 = intset_self == intset_ob;
    t34 = t35;
  };
  if (t34){
    object_Dec_ref(intset_self);
    object_Dec_ref(intset_ob);
    t36 = mem_malloc(48); ((cptr)t36)[0] = sset_methods;
    t37 = sset_alloc((cint)t36);
    t30 = t37;
    goto t30_label;
  }else{
    t38 = rset_Minus((cint)intset_self, (cint)intset_ob);
    t30 = t38;
    goto t30_label;
  };
  t30 = intset_result;
  goto t30_label;
  t30_label: return t30;
}

cint intset_Mkstr(cint intset_self){
  cint intset_result;
  cint t39, t40, t41, t42, t43, t44, t45, t46, t47, t48, t49, t50, t51;
  ((cptr)strpool_str_13)[1] += 1;
  ((cptr)strpool_str_159)[1] += 1;
  t40 = ((cptr)(((cptr)strpool_str_13)[0]))[97];
  t41 = ((f0)t40)((cint)strpool_str_13, (cint)strpool_str_159); /* Plus*/
  ((cptr)strpool_str_12)[1] += 1;
  t43 = ((cptr)(((cptr)t41)[0]))[97];
  t44 = ((f0)t43)((cint)t41, (cint)strpool_str_12); /* Plus*/
  ((cptr)strpool_str_5)[1] += 1;
  t46 = ((cptr)(((cptr)t44)[0]))[97];
  t47 = ((f0)t46)((cint)t44, (cint)strpool_str_5); /* Plus*/
  ((cptr)strpool_str_15)[1] += 1;
  t49 = ((cptr)(((cptr)t47)[0]))[97];
  t50 = ((f0)t49)((cint)t47, (cint)strpool_str_15); /* Plus*/
  intset_result = t50;
  object_Dec_ref(intset_self);
  t39 = intset_result;
  goto t39_label;
  t39_label: return t39;
}

cint intset_Plus(cint intset_self, cint intset_ob){
  cint intset_result, intset_os;
  cint t52, t53, t54, t55, t56;
  intset_os = intset_ob;
  t53 = ((cptr)intset_ob)[4] /* class_of*/ == strpool_str_32;
  t54 = t53;
  if (t54){
    t55 = ((cptr)intset_os)[7] /* elemtype*/ == intset_predef;
    t54 = t55;
  };
  if (t54){
    object_Dec_ref(intset_ob);
    t52 = intset_self;
    goto t52_label;
  };
  t56 = rset_Plus((cint)intset_self, (cint)intset_ob);
  t52 = t56;
  goto t52_label;
  t52_label: return t52;
}

cint intset_Subset(cint intset_self, cint intset_ob){
  cint intset_result, intset_os;
  cint t57, t58, t59, t60, t61, t62, t63, t64, t65, t66, t67, t68, t69, t70, t71;
  t58 = ((cptr)intset_ob)[5] /* representation*/ == strpool_str_56;
  t59 = t58;
  if (!t59){    t60 = ((cptr)intset_ob)[5] /* representation*/ == strpool_str_31;
    t59 = t60;
  };
  t61 = t59;
  if (!t61){    t62 = intset_self == intset_ob;
    t61 = t62;
  };
  if (t61){
    object_Dec_ref(intset_self);
    object_Dec_ref(intset_ob);
    t57 = boolean_True;
    goto t57_label;
  }else{
  t63 = ((cptr)intset_ob)[5] /* representation*/ == strpool_str_49;
  if (t63){
    intset_os = intset_ob;
    ((cptr)intset_self)[1] += 1;
    ((cptr)((cptr)intset_os)[8] /* subset1*/)[1] += 1;
    t64 = ((cptr)(((cptr)intset_self)[0]))[104];
    t65 = ((f0)t64)((cint)intset_self, (cint)((cptr)intset_os)[8] /* subset1*/); /* Subset*/
    intset_result = t65;
    t67 = intset_result == boolean_False;
    if (t67){
      ((cptr)intset_self)[1] += 1;
      ((cptr)((cptr)intset_os)[9] /* subset2*/)[1] += 1;
      t68 = ((cptr)(((cptr)intset_self)[0]))[104];
      t69 = ((f0)t68)((cint)intset_self, (cint)((cptr)intset_os)[9] /* subset2*/); /* Subset*/
      intset_result = t69;
    };
    object_Dec_ref(intset_self);
    object_Dec_ref(intset_ob);
  }else{
    t71 = rset_Subset((cint)intset_self, (cint)intset_ob);
    t57 = t71;
    goto t57_label;
  };};
  t57 = intset_result;
  goto t57_label;
  t57_label: return t57;
}

void init_intset(){
  copy_meth_table(intset_methods, rset_methods);
  intset_methods[0] = 44;
  intset_methods[1] = intset_init;
  intset_methods[2] = intset_fini;
  intset_methods[3] = intset_alloc;
  intset_methods[4] = intset_reclaim;
  intset_methods[20] = intset_Contains;
  intset_methods[37] = intset_equal;
  intset_methods[41] = intset_Expanded_with;
  intset_methods[54] = intset_Intersect;
  intset_methods[83] = intset_Minus;
  intset_methods[88] = intset_Mkstr;
  intset_methods[97] = intset_Plus;
  intset_methods[104] = intset_Subset;
}
