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

extern cint boolean_True;
extern cint entset_predef;
extern cint boolean_False;
extern cint object_Undefined;
extern cint strpool_str_69;
extern cint strpool_str_4;

cint boolset_predef;

cptr boolset_methods[meth_max];

cint boolset_init(){
  cint t1, t2, t3;
  t2 = mem_malloc(32); ((cptr)t2)[0] = boolset_methods;
  t3 = boolset_alloc((cint)t2);
  boolset_predef = t3;
  t1_label: return t1;
}

cint boolset_fini(){
  cint t4;
  object_Dec_ref(boolset_predef);
  t4_label: return t4;
}

cint boolset_alloc(cint boolset_self){
  cint boolset_result;
  cint t5, t6;
  t6 = set_alloc((cint)boolset_self);
  boolset_result = t6;
  ((cptr)boolset_self)[5] /* representation*/ = strpool_str_69;
  ((cptr)boolset_self)[3] /* len*/ = 2;
  t5 = boolset_result;
  goto t5_label;
  t5_label: return t5;
}

cint boolset_reclaim(cint boolset_self){
  cint t7;
  set_reclaim((cint)boolset_self);
  t7_label: return t7;
}

cint boolset_Append(cint boolset_self, cint boolset_item){
  cint boolset_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)boolset_item); /* Append*/
  t14 = ((cptr)(((cptr)t12)[0]))[97];
  t15 = ((f0)t14)((cint)t12, (cint)boolset_self); /* Plus*/
  t8 = t15;
  goto t8_label;
  t8_label: return t8;
}

cint boolset_Contains(cint boolset_self, cint boolset_ob){
  cint boolset_result;
  cint t17, t18;
  boolset_result = boolean_False;
  t18 = ((cptr)boolset_ob)[4] /* class_of*/ == strpool_str_4;
  if (t18){
    boolset_result = boolean_True;
  };
  object_Dec_ref(boolset_self);
  object_Dec_ref(boolset_ob);
  t17 = boolset_result;
  goto t17_label;
  t17_label: return t17;
}

cint boolset_Expanded_with(cint boolset_self, cint boolset_ob){
  cint boolset_result;
  cint t19, t20;
  t20 = ((cptr)boolset_ob)[5] /* representation*/ == strpool_str_4;
  if (t20){
    t19 = boolset_self;
    goto t19_label;
  };
  object_Dec_ref(boolset_self);
  ((cptr)entset_predef)[1] += 1;
  t19 = entset_predef;
  goto t19_label;
  t19_label: return t19;
}

cint boolset_lookup(cint boolset_self, cint boolset_i){
  cint boolset_result;
  cint t21, t22, t23;
  t22 = boolset_i == 2;
  if (t22){
    t21 = boolean_True;
    goto t21_label;
  };
  t23 = boolset_i == 1;
  if (t23){
    t21 = boolean_False;
    goto t21_label;
  };
  t21 = object_Undefined;
  goto t21_label;
  t21_label: return t21;
}

cint boolset_Plus(cint boolset_self, cint boolset_ob){
  cint boolset_result;
  cint t24, t25, t26, t27, t28, t29, t30;
  t25 = ((cptr)(((cptr)boolset_ob)[0]))[7];
  t26 = ((f0)t25)((cint)boolset_ob, (cint)boolean_False); /* Append*/
  t28 = ((cptr)(((cptr)t26)[0]))[7];
  t29 = ((f0)t28)((cint)t26, (cint)boolean_True); /* Append*/
  boolset_result = t29;
  object_Dec_ref(boolset_self);
  t24 = boolset_result;
  goto t24_label;
  t24_label: return t24;
}

void init_boolset(){
  copy_meth_table(boolset_methods, set_methods);
  boolset_methods[0] = 32;
  boolset_methods[1] = boolset_init;
  boolset_methods[2] = boolset_fini;
  boolset_methods[3] = boolset_alloc;
  boolset_methods[4] = boolset_reclaim;
  boolset_methods[7] = boolset_Append;
  boolset_methods[20] = boolset_Contains;
  boolset_methods[41] = boolset_Expanded_with;
  boolset_methods[62] = boolset_lookup;
  boolset_methods[97] = boolset_Plus;
}
