#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 boolean_methods[meth_max];
extern cptr collection_methods[meth_max];
extern cptr string_methods[meth_max];
#include "cint.h"
extern cptr strpool_methods[meth_max];
extern cptr intset_methods[meth_max];
extern cptr pset_methods[meth_max];

extern cint strpool_str_5;
extern cint boolean_True;
extern cint boolean_False;
extern cint intset_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;
extern cint strpool_str_68;

cint numset_predef;

cptr numset_methods[meth_max];

cint numset_init(){
  cint t1, t2, t3;
  t2 = mem_malloc(32); ((cptr)t2)[0] = numset_methods;
  t3 = numset_alloc((cint)t2);
  numset_predef = t3;
  t1_label: return t1;
}

cint numset_fini(){
  cint t4;
  object_Dec_ref(numset_predef);
  t4_label: return t4;
}

cint numset_alloc(cint numset_self){
  cint numset_result;
  cint t5, t6;
  t6 = set_alloc((cint)numset_self);
  numset_result = t6;
  ((cptr)numset_self)[5] /* representation*/ = strpool_str_56;
  ((cptr)numset_self)[3] /* len*/ = -1;
  t5 = numset_result;
  goto t5_label;
  t5_label: return t5;
}

cint numset_reclaim(cint numset_self){
  cint t7;
  set_reclaim((cint)numset_self);
  t7_label: return t7;
}

cint numset_Append(cint numset_self, cint numset_item){
  cint numset_result;
  cint t8, t9, t10, t11, t12, t13, t14, t15, t16;
  t9 = mem_malloc(48); ((cptr)t9)[0] = sset_methods;
  t10 = sset_alloc((cint)t9);
  t11 = ((cptr)(((cptr)t10)[0]))[7];
  t12 = ((f0)t11)((cint)t10, (cint)numset_item); /* Append*/
  t14 = ((cptr)(((cptr)t12)[0]))[97];
  t15 = ((f0)t14)((cint)t12, (cint)numset_self); /* Plus*/
  t8 = t15;
  goto t8_label;
  t8_label: return t8;
}

cint numset_Contains(cint numset_self, cint numset_ob){
  cint numset_result;
  cint t17, t18, t19;
  numset_result = boolean_False;
  t18 = ((cptr)numset_ob)[4] /* class_of*/ == strpool_str_5;
  if (t18){
    numset_result = boolean_True;
  };
  t19 = ((cptr)numset_ob)[4] /* class_of*/ == strpool_str_19;
  if (t19){
    numset_result = boolean_True;
  };
  object_Dec_ref(numset_self);
  object_Dec_ref(numset_ob);
  t17 = numset_result;
  goto t17_label;
  t17_label: return t17;
}

cint numset_equal(cint numset_self, cint numset_ob){
  cint numset_result;
  cint t20, t21;
  t21 = numset_self == numset_ob;
  if (t21){
    t20 = 1;
    goto t20_label;
  };
  t20 = 0;
  goto t20_label;
  t20_label: return t20;
}

cint numset_Intersect(cint numset_self, cint numset_ob){
  cint numset_result;
  cint t22, t23, t24, t25, t26, t27;
  t23 = ((cptr)numset_ob)[5] /* representation*/ == strpool_str_31;
  t24 = t23;
  if (!t24){    t25 = ((cptr)numset_ob)[5] /* representation*/ == strpool_str_56;
    t24 = t25;
  };
  if (t24){
    object_Dec_ref(numset_ob);
    t22 = numset_self;
    goto t22_label;
  }else{
  t26 = numset_ob == intset_predef;
  if (t26){
    object_Dec_ref(numset_self);
    t22 = numset_ob;
    goto t22_label;
  }else{
    t27 = set_Intersect((cint)numset_self, (cint)numset_ob);
    t22 = t27;
    goto t22_label;
  };};
  t22 = numset_result;
  goto t22_label;
  t22_label: return t22;
}

cint numset_Minus(cint numset_self, cint numset_ob){
  cint numset_result;
  cint t28, t29, t30, t31, t32, t33, t34;
  t29 = ((cptr)numset_ob)[5] /* representation*/ == strpool_str_31;
  t30 = t29;
  if (!t30){    t31 = ((cptr)numset_ob)[5] /* representation*/ == strpool_str_56;
    t30 = t31;
  };
  if (t30){
    object_Dec_ref(numset_self);
    object_Dec_ref(numset_ob);
    t32 = mem_malloc(48); ((cptr)t32)[0] = sset_methods;
    t33 = sset_alloc((cint)t32);
    t28 = t33;
    goto t28_label;
  }else{
    t34 = set_Minus((cint)numset_self, (cint)numset_ob);
    t28 = t34;
    goto t28_label;
  };
  t28 = numset_result;
  goto t28_label;
  t28_label: return t28;
}

cint numset_Mkstr(cint numset_self){
  cint numset_result;
  cint t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47;
  ((cptr)strpool_str_13)[1] += 1;
  ((cptr)strpool_str_159)[1] += 1;
  t36 = ((cptr)(((cptr)strpool_str_13)[0]))[97];
  t37 = ((f0)t36)((cint)strpool_str_13, (cint)strpool_str_159); /* Plus*/
  ((cptr)strpool_str_12)[1] += 1;
  t39 = ((cptr)(((cptr)t37)[0]))[97];
  t40 = ((f0)t39)((cint)t37, (cint)strpool_str_12); /* Plus*/
  ((cptr)strpool_str_68)[1] += 1;
  t42 = ((cptr)(((cptr)t40)[0]))[97];
  t43 = ((f0)t42)((cint)t40, (cint)strpool_str_68); /* Plus*/
  ((cptr)strpool_str_15)[1] += 1;
  t45 = ((cptr)(((cptr)t43)[0]))[97];
  t46 = ((f0)t45)((cint)t43, (cint)strpool_str_15); /* Plus*/
  numset_result = t46;
  object_Dec_ref(numset_self);
  t35 = numset_result;
  goto t35_label;
  t35_label: return t35;
}

cint numset_Plus(cint numset_self, cint numset_ob){
  cint numset_result, numset_os;
  cint t48, t49, t50, t51, t52, t53, t54;
  t49 = ((cptr)numset_ob)[4] /* class_of*/ == strpool_str_32;
  if (t49){
    numset_os = numset_ob;
    t50 = ((cptr)numset_os)[7] /* elemtype*/ == numset_self;
    t51 = t50;
    if (!t51){      t52 = ((cptr)numset_os)[7] /* elemtype*/ == intset_predef;
      t51 = t52;
    };
    if (t51){
      object_Dec_ref(numset_ob);
      t48 = numset_self;
      goto t48_label;
    }else{
    t53 = ((cptr)numset_ob)[5] /* representation*/ == strpool_str_31;
    if (t53){
      object_Dec_ref(numset_self);
      t48 = numset_ob;
      goto t48_label;
    };};
  };
  t54 = set_Plus((cint)numset_self, (cint)numset_ob);
  t48 = t54;
  goto t48_label;
  t48_label: return t48;
}

cint numset_Subset(cint numset_self, cint numset_ob){
  cint numset_result, numset_os;
  cint t55, t56, t57, t58, t59, t60, t61, t62, t63, t64, t65, t66, t67;
  t56 = ((cptr)numset_ob)[5] /* representation*/ == strpool_str_31;
  t57 = t56;
  if (!t57){    t58 = ((cptr)numset_ob)[5] /* representation*/ == strpool_str_56;
    t57 = t58;
  };
  if (t57){
    object_Dec_ref(numset_self);
    object_Dec_ref(numset_ob);
    t55 = boolean_True;
    goto t55_label;
  }else{
  t59 = ((cptr)numset_ob)[5] /* representation*/ == strpool_str_49;
  if (t59){
    numset_os = numset_ob;
    ((cptr)numset_self)[1] += 1;
    ((cptr)((cptr)numset_os)[8] /* subset1*/)[1] += 1;
    t60 = ((cptr)(((cptr)numset_self)[0]))[104];
    t61 = ((f0)t60)((cint)numset_self, (cint)((cptr)numset_os)[8] /* subset1*/); /* Subset*/
    numset_result = t61;
    t63 = numset_result == boolean_False;
    if (t63){
      ((cptr)numset_self)[1] += 1;
      ((cptr)((cptr)numset_os)[9] /* subset2*/)[1] += 1;
      t64 = ((cptr)(((cptr)numset_self)[0]))[104];
      t65 = ((f0)t64)((cint)numset_self, (cint)((cptr)numset_os)[9] /* subset2*/); /* Subset*/
      numset_result = t65;
    };
    object_Dec_ref(numset_self);
    object_Dec_ref(numset_ob);
  }else{
    t67 = collection_Subset((cint)numset_self, (cint)numset_ob);
    t55 = t67;
    goto t55_label;
  };};
  t55 = numset_result;
  goto t55_label;
  t55_label: return t55;
}

void init_numset(){
  copy_meth_table(numset_methods, set_methods);
  numset_methods[0] = 32;
  numset_methods[1] = numset_init;
  numset_methods[2] = numset_fini;
  numset_methods[3] = numset_alloc;
  numset_methods[4] = numset_reclaim;
  numset_methods[7] = numset_Append;
  numset_methods[20] = numset_Contains;
  numset_methods[37] = numset_equal;
  numset_methods[54] = numset_Intersect;
  numset_methods[83] = numset_Minus;
  numset_methods[88] = numset_Mkstr;
  numset_methods[97] = numset_Plus;
  numset_methods[104] = numset_Subset;
}
