#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr set_methods[meth_max];
extern cptr rset_methods[meth_max];
extern cptr boolean_methods[meth_max];
extern cptr string_methods[meth_max];
extern cptr character_methods[meth_max];
extern cptr strset_methods[meth_max];
extern cptr entset_methods[meth_max];
extern cptr collection_methods[meth_max];
extern cptr strpool_methods[meth_max];

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

cint charset_predef;

cptr charset_methods[meth_max];

cint charset_init(){
  cint t1, t2, t3;
  t2 = mem_malloc(44); ((cptr)t2)[0] = charset_methods;
  charset_predef = t2;
  t3 = charset_alloc((cint)charset_predef);
  charset_predef = t3;
  t1_label: return t1;
}

cint charset_fini(){
  cint t4;
  object_Dec_ref(charset_predef);
  t4_label: return t4;
}

cint charset_alloc(cint charset_self){
  cint charset_result, charset_ch0, charset_ch255;
  cint t5, t6, t7, t8, t9, t10;
  t6 = mem_malloc(36); ((cptr)t6)[0] = character_methods;
  t7 = character_alloc((cint)t6, (cint)0, (cint)0);
  charset_ch0 = t7;
  t8 = mem_malloc(36); ((cptr)t8)[0] = character_methods;
  t9 = character_alloc((cint)t8, (cint)255, (cint)0);
  charset_ch255 = t9;
  t10 = rset_alloc((cint)charset_self, (cint)charset_ch0, (cint)charset_ch255);
  charset_result = t10;
  t5 = charset_result;
  goto t5_label;
  t5_label: return t5;
}

cint charset_reclaim(cint charset_self){
  cint t11;
  rset_reclaim((cint)charset_self);
  t11_label: return t11;
}

cint charset_Contains(cint charset_self, cint charset_ob){
  cint charset_result;
  cint t12, t13, t14, t15;
  charset_result = boolean_False;
  t13 = ((cptr)charset_ob)[4] /* class_of*/ == strpool_str_6;
  t14 = t13;
  if (t14){
    t15 = ((cptr)charset_ob)[3] /* len*/ == 1;
    t14 = t15;
  };
  if (t14){
    charset_result = boolean_True;
  };
  object_Dec_ref(charset_self);
  object_Dec_ref(charset_ob);
  t12 = charset_result;
  goto t12_label;
  t12_label: return t12;
}

cint charset_Expanded_with(cint charset_self, cint charset_ob){
  cint charset_result;
  cint t16, t17, t18;
  t17 = ((cptr)charset_ob)[5] /* representation*/ == strpool_str_7;
  if (t17){
    t16 = charset_self;
    goto t16_label;
  };
  object_Dec_ref(charset_self);
  t18 = ((cptr)charset_ob)[4] /* class_of*/ == strpool_str_6;
  if (t18){
    ((cptr)strset_predef)[1] += 1;
    t16 = strset_predef;
    goto t16_label;
  };
  ((cptr)entset_predef)[1] += 1;
  t16 = entset_predef;
  goto t16_label;
  t16_label: return t16;
}

cint charset_Intersect(cint charset_self, cint charset_ob){
  cint charset_result;
  cint t19, t20, t21, t22, t23;
  t20 = ((cptr)charset_ob)[5] /* representation*/ == strpool_str_57;
  t21 = t20;
  if (!t21){    t22 = ((cptr)charset_ob)[5] /* representation*/ == strpool_str_31;
    t21 = t22;
  };
  if (t21){
    object_Dec_ref(charset_ob);
    t19 = charset_self;
    goto t19_label;
  };
  t23 = rset_Intersect((cint)charset_self, (cint)charset_ob);
  t19 = t23;
  goto t19_label;
  t19_label: return t19;
}

cint charset_Mkstr(cint charset_self){
  cint charset_result;
  cint t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36;
  ((cptr)strpool_str_13)[1] += 1;
  ((cptr)strpool_str_159)[1] += 1;
  t25 = ((cptr)(((cptr)strpool_str_13)[0]))[97];
  t26 = ((f0)t25)((cint)strpool_str_13, (cint)strpool_str_159); /* Plus*/
  ((cptr)strpool_str_12)[1] += 1;
  t28 = ((cptr)(((cptr)t26)[0]))[97];
  t29 = ((f0)t28)((cint)t26, (cint)strpool_str_12); /* Plus*/
  ((cptr)strpool_str_7)[1] += 1;
  t31 = ((cptr)(((cptr)t29)[0]))[97];
  t32 = ((f0)t31)((cint)t29, (cint)strpool_str_7); /* Plus*/
  ((cptr)strpool_str_15)[1] += 1;
  t34 = ((cptr)(((cptr)t32)[0]))[97];
  t35 = ((f0)t34)((cint)t32, (cint)strpool_str_15); /* Plus*/
  charset_result = t35;
  object_Dec_ref(charset_self);
  t24 = charset_result;
  goto t24_label;
  t24_label: return t24;
}

cint charset_Subset(cint charset_self, cint charset_ob){
  cint charset_result;
  cint t37, t38, t39, t40, t41;
  t38 = ((cptr)charset_ob)[5] /* representation*/ == strpool_str_57;
  t39 = t38;
  if (!t39){    t40 = ((cptr)charset_ob)[5] /* representation*/ == strpool_str_31;
    t39 = t40;
  };
  if (t39){
    object_Dec_ref(charset_self);
    object_Dec_ref(charset_ob);
    t37 = boolean_True;
    goto t37_label;
  };
  t41 = collection_Subset((cint)charset_self, (cint)charset_ob);
  t37 = t41;
  goto t37_label;
  t37_label: return t37;
}

void init_charset(){
  copy_meth_table(charset_methods, rset_methods);
  charset_methods[0] = 44;
  charset_methods[1] = charset_init;
  charset_methods[2] = charset_fini;
  charset_methods[3] = charset_alloc;
  charset_methods[4] = charset_reclaim;
  charset_methods[20] = charset_Contains;
  charset_methods[41] = charset_Expanded_with;
  charset_methods[54] = charset_Intersect;
  charset_methods[88] = charset_Mkstr;
  charset_methods[104] = charset_Subset;
}
