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

extern cint boolean_True;
extern cint strpool_str_6;
extern cint entset_predef;
extern cint boolean_False;
extern cint charset_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_57;
extern cint strpool_str_49;

cint strset_predef;

cptr strset_methods[meth_max];

cint strset_init(){
  cint t1, t2, t3;
  t2 = mem_malloc(32); ((cptr)t2)[0] = strset_methods;
  t3 = strset_alloc((cint)t2);
  strset_predef = t3;
  t1_label: return t1;
}

cint strset_fini(){
  cint t4;
  object_Dec_ref(strset_predef);
  t4_label: return t4;
}

cint strset_alloc(cint strset_self){
  cint strset_result;
  cint t5, t6;
  t6 = set_alloc((cint)strset_self);
  strset_result = t6;
  ((cptr)strset_self)[5] /* representation*/ = strpool_str_57;
  ((cptr)strset_self)[3] /* len*/ = -1;
  t5 = strset_result;
  goto t5_label;
  t5_label: return t5;
}

cint strset_reclaim(cint strset_self){
  cint t7;
  set_reclaim((cint)strset_self);
  t7_label: return t7;
}

cint strset_Contains(cint strset_self, cint strset_ob){
  cint strset_result;
  cint t8, t9;
  strset_result = boolean_False;
  t9 = ((cptr)strset_ob)[4] /* class_of*/ == strpool_str_6;
  if (t9){
    strset_result = boolean_True;
  };
  object_Dec_ref(strset_self);
  object_Dec_ref(strset_ob);
  t8 = strset_result;
  goto t8_label;
  t8_label: return t8;
}

cint strset_Expanded_with(cint strset_self, cint strset_ob){
  cint strset_result;
  cint t10, t11;
  t11 = ((cptr)strset_ob)[5] /* representation*/ == strpool_str_6;
  if (t11){
    t10 = strset_self;
    goto t10_label;
  };
  object_Dec_ref(strset_self);
  ((cptr)entset_predef)[1] += 1;
  t10 = entset_predef;
  goto t10_label;
  t10_label: return t10;
}

cint strset_Intersect(cint strset_self, cint strset_ob){
  cint strset_result;
  cint t12, t13, t14, t15, t16, t17;
  t13 = ((cptr)strset_ob)[5] /* representation*/ == strpool_str_31;
  t14 = t13;
  if (!t14){    t15 = ((cptr)strset_ob)[5] /* representation*/ == strpool_str_57;
    t14 = t15;
  };
  if (t14){
    object_Dec_ref(strset_ob);
    t12 = strset_self;
    goto t12_label;
  }else{
  t16 = strset_ob == charset_predef;
  if (t16){
    object_Dec_ref(strset_self);
    t12 = strset_ob;
    goto t12_label;
  }else{
    t17 = set_Intersect((cint)strset_self, (cint)strset_ob);
    t12 = t17;
    goto t12_label;
  };};
  t12 = strset_result;
  goto t12_label;
  t12_label: return t12;
}

cint strset_Minus(cint strset_self, cint strset_ob){
  cint strset_result;
  cint t18, t19, t20, t21, t22, t23, t24;
  t19 = ((cptr)strset_ob)[5] /* representation*/ == strpool_str_31;
  t20 = t19;
  if (!t20){    t21 = ((cptr)strset_ob)[5] /* representation*/ == strpool_str_57;
    t20 = t21;
  };
  if (t20){
    object_Dec_ref(strset_self);
    object_Dec_ref(strset_ob);
    t22 = mem_malloc(48); ((cptr)t22)[0] = sset_methods;
    t23 = sset_alloc((cint)t22);
    t18 = t23;
    goto t18_label;
  }else{
    t24 = set_Minus((cint)strset_self, (cint)strset_ob);
    t18 = t24;
    goto t18_label;
  };
  t18 = strset_result;
  goto t18_label;
  t18_label: return t18;
}

cint strset_Mkstr(cint strset_self){
  cint strset_result;
  cint t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37;
  ((cptr)strpool_str_13)[1] += 1;
  ((cptr)strpool_str_159)[1] += 1;
  t26 = ((cptr)(((cptr)strpool_str_13)[0]))[97];
  t27 = ((f0)t26)((cint)strpool_str_13, (cint)strpool_str_159); /* Plus*/
  ((cptr)strpool_str_12)[1] += 1;
  t29 = ((cptr)(((cptr)t27)[0]))[97];
  t30 = ((f0)t29)((cint)t27, (cint)strpool_str_12); /* Plus*/
  ((cptr)strpool_str_6)[1] += 1;
  t32 = ((cptr)(((cptr)t30)[0]))[97];
  t33 = ((f0)t32)((cint)t30, (cint)strpool_str_6); /* Plus*/
  ((cptr)strpool_str_15)[1] += 1;
  t35 = ((cptr)(((cptr)t33)[0]))[97];
  t36 = ((f0)t35)((cint)t33, (cint)strpool_str_15); /* Plus*/
  strset_result = t36;
  object_Dec_ref(strset_self);
  t25 = strset_result;
  goto t25_label;
  t25_label: return t25;
}

cint strset_Plus(cint strset_self, cint strset_ob){
  cint strset_result, strset_os;
  cint t38, t39, t40, t41, t42, t43, t44;
  t39 = ((cptr)strset_ob)[4] /* class_of*/ == strpool_str_32;
  if (t39){
    strset_os = strset_ob;
    t40 = ((cptr)strset_os)[7] /* elemtype*/ == strset_self;
    t41 = t40;
    if (!t41){      t42 = ((cptr)strset_os)[7] /* elemtype*/ == charset_predef;
      t41 = t42;
    };
    if (t41){
      object_Dec_ref(strset_ob);
      t38 = strset_self;
      goto t38_label;
    }else{
    t43 = ((cptr)strset_ob)[5] /* representation*/ == strpool_str_31;
    if (t43){
      object_Dec_ref(strset_self);
      t38 = strset_ob;
      goto t38_label;
    };};
  };
  t44 = set_Plus((cint)strset_self, (cint)strset_ob);
  t38 = t44;
  goto t38_label;
  t38_label: return t38;
}

cint strset_Subset(cint strset_self, cint strset_ob){
  cint strset_result, strset_os;
  cint t45, t46, t47, t48, t49, t50, t51, t52, t53, t54, t55, t56, t57;
  t46 = ((cptr)strset_ob)[5] /* representation*/ == strpool_str_31;
  t47 = t46;
  if (!t47){    t48 = ((cptr)strset_ob)[5] /* representation*/ == strpool_str_57;
    t47 = t48;
  };
  if (t47){
    object_Dec_ref(strset_self);
    object_Dec_ref(strset_ob);
    t45 = boolean_True;
    goto t45_label;
  }else{
  t49 = ((cptr)strset_ob)[5] /* representation*/ == strpool_str_49;
  if (t49){
    strset_os = strset_ob;
    ((cptr)strset_self)[1] += 1;
    ((cptr)((cptr)strset_os)[8] /* subset1*/)[1] += 1;
    t50 = ((cptr)(((cptr)strset_self)[0]))[104];
    t51 = ((f0)t50)((cint)strset_self, (cint)((cptr)strset_os)[8] /* subset1*/); /* Subset*/
    strset_result = t51;
    t53 = strset_result == boolean_False;
    if (t53){
      ((cptr)strset_self)[1] += 1;
      ((cptr)((cptr)strset_os)[9] /* subset2*/)[1] += 1;
      t54 = ((cptr)(((cptr)strset_self)[0]))[104];
      t55 = ((f0)t54)((cint)strset_self, (cint)((cptr)strset_os)[9] /* subset2*/); /* Subset*/
      strset_result = t55;
    };
    object_Dec_ref(strset_self);
    object_Dec_ref(strset_ob);
  }else{
    t57 = collection_Subset((cint)strset_self, (cint)strset_ob);
    t45 = t57;
    goto t45_label;
  };};
  t45 = strset_result;
  goto t45_label;
  t45_label: return t45;
}

void init_strset(){
  copy_meth_table(strset_methods, set_methods);
  strset_methods[0] = 32;
  strset_methods[1] = strset_init;
  strset_methods[2] = strset_fini;
  strset_methods[3] = strset_alloc;
  strset_methods[4] = strset_reclaim;
  strset_methods[20] = strset_Contains;
  strset_methods[41] = strset_Expanded_with;
  strset_methods[54] = strset_Intersect;
  strset_methods[83] = strset_Minus;
  strset_methods[88] = strset_Mkstr;
  strset_methods[97] = strset_Plus;
  strset_methods[104] = strset_Subset;
}
