#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr collection_methods[meth_max];
extern cptr integer_methods[meth_max];
extern cptr character_methods[meth_max];
extern cptr list_methods[meth_max];
extern cptr slist_methods[meth_max];
extern cptr boolean_methods[meth_max];
#include "cint.h"
extern cptr intset_methods[meth_max];
extern cptr charset_methods[meth_max];
extern cptr strpool_methods[meth_max];
#include "cstring.h"
extern cptr rlist_methods[meth_max];

extern cint strpool_str_5;
extern cint strpool_str_6;
extern cint boolean_True;
extern cint object_Undefined;
extern cint intset_predef;
extern cint boolean_False;
extern cint charset_predef;
extern cint strpool_str_44;
extern cint strpool_str_47;
extern cint strpool_str_48;


cptr srlist_methods[meth_max];

cint srlist_alloc(cint srlist_self, cint srlist_rstart, cint srlist_rend, cint srlist_incr){
  cint srlist_result, srlist_i, srlist_j;
  cint t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t31, t32, t33, t34, t35, t36, t37, t38, t39, t42, t43, t44, t45, t46, t47, t48;
  t2 = list_alloc((cint)srlist_self);
  srlist_result = t2;
  t3 = ((cptr)srlist_incr)[4] /* class_of*/ == strpool_str_5;
  t4 = t3;
  if (t4){
    t5 = ((cptr)srlist_incr)[2] /* hashval*/ == 1;
    t4 = t5;
  };
  if (t4){
    cstring_mem_free((cint)srlist_self);
    object_Dec_ref(srlist_incr);
    t6 = mem_malloc(44); ((cptr)t6)[0] = rlist_methods;
    t7 = rlist_alloc((cint)t6, (cint)srlist_rstart, (cint)srlist_rend);
    t1 = t7;
    goto t1_label;
  };
  t8 = ((cptr)srlist_rstart)[4] /* class_of*/ == strpool_str_5;
  t9 = t8;
  if (t9){
    t10 = ((cptr)srlist_rend)[4] /* class_of*/ == strpool_str_5;
    t9 = t10;
  };
  t11 = t9;
  if (t11){
    t12 = ((cptr)srlist_incr)[4] /* class_of*/ == strpool_str_5;
    t11 = t12;
  };
  if (t11){
    ((cptr)intset_predef)[1] += 1;
    ((cptr)srlist_self)[7] /* elemtype*/ = intset_predef;
    t13 = mem_malloc(28); ((cptr)t13)[0] = integer_methods;
    t14 = integer_ialloc((cint)t13, (cint)0);
    ((cptr)srlist_self)[8] /* elem*/ = t14;
  }else{
  t15 = ((cptr)srlist_rstart)[4] /* class_of*/ == strpool_str_6;
  t16 = t15;
  if (t16){
    t17 = ((cptr)srlist_rstart)[3] /* len*/ == 1;
    t16 = t17;
  };
  t18 = t16;
  if (t18){
    t19 = ((cptr)srlist_rend)[4] /* class_of*/ == strpool_str_6;
    t18 = t19;
  };
  t20 = t18;
  if (t20){
    t21 = ((cptr)srlist_rend)[3] /* len*/ == 1;
    t20 = t21;
  };
  t22 = t20;
  if (t22){
    t23 = ((cptr)srlist_incr)[4] /* class_of*/ == strpool_str_5;
    t22 = t23;
  };
  if (t22){
    ((cptr)charset_predef)[1] += 1;
    ((cptr)srlist_self)[7] /* elemtype*/ = charset_predef;
    t24 = mem_malloc(36); ((cptr)t24)[0] = character_methods;
    t25 = character_alloc((cint)t24, (cint)0, (cint)0);
    ((cptr)srlist_self)[8] /* elem*/ = t25;
  }else{
    object_Dec_ref(srlist_rstart);
    object_Dec_ref(srlist_rend);
    list_reclaim((cint)srlist_self);
    t1 = object_Undefined;
    goto t1_label;
  };};
  ((cptr)srlist_self)[5] /* representation*/ = strpool_str_47;
  ((cptr)srlist_self)[9] /* r_start*/ = srlist_rstart;
  ((cptr)srlist_self)[10] /* r_end*/ = srlist_rend;
  ((cptr)srlist_self)[11] /* r_incr*/ = srlist_incr;
  srlist_i = ((cptr)srlist_rstart)[2] /* hashval*/;
  ((cptr)srlist_self)[3] /* len*/ = 0;
  ((cptr)srlist_self)[2] /* hashval*/ = 0;
  t26 = ((cptr)srlist_rstart)[2] /* hashval*/ <= ((cptr)srlist_rend)[2] /* hashval*/;
  t27 = t26;
  if (t27){
    t28 = ((cptr)srlist_incr)[2] /* hashval*/ > 0;
    t27 = t28;
  };
  if (t27){
    t29:
    t31 = srlist_i <= ((cptr)srlist_rend)[2] /* hashval*/;
    if (!t31) goto t30;
      t32 = ((cptr)srlist_self)[3] /* len*/ + 1;
      ((cptr)srlist_self)[3] /* len*/ = t32;
      t33 = ((cptr)srlist_self)[2] /* hashval*/ + srlist_i;
      ((cptr)srlist_self)[2] /* hashval*/ = t33;
      t34 = srlist_i + ((cptr)srlist_incr)[2] /* hashval*/;
      srlist_j = t34;
      t35 = srlist_j < srlist_i;
      if (t35){
        goto t30;
      };
      srlist_i = srlist_j;
    goto t29;
    t30:;
    t36 = ((cptr)srlist_self)[3] /* len*/ <= 0;
    if (t36){
      ((cptr)srlist_self)[3] /* len*/ = -1;
    };
  }else{
  t37 = ((cptr)srlist_rstart)[2] /* hashval*/ > ((cptr)srlist_rend)[2] /* hashval*/;
  t38 = t37;
  if (t38){
    t39 = ((cptr)srlist_incr)[2] /* hashval*/ < 0;
    t38 = t39;
  };
  if (t38){
    t40:
    t42 = srlist_i >= ((cptr)srlist_rend)[2] /* hashval*/;
    if (!t42) goto t41;
      t43 = ((cptr)srlist_self)[3] /* len*/ + 1;
      ((cptr)srlist_self)[3] /* len*/ = t43;
      t44 = ((cptr)srlist_self)[2] /* hashval*/ + srlist_i;
      ((cptr)srlist_self)[2] /* hashval*/ = t44;
      t45 = srlist_i + ((cptr)srlist_incr)[2] /* hashval*/;
      srlist_j = t45;
      t46 = srlist_j > srlist_i;
      if (t46){
        goto t41;
      };
      srlist_i = srlist_j;
    goto t40;
    t41:;
    t47 = ((cptr)srlist_self)[3] /* len*/ <= 0;
    if (t47){
      ((cptr)srlist_self)[3] /* len*/ = -1;
    };
  }else{
  t48 = ((cptr)srlist_rstart)[2] /* hashval*/ == ((cptr)srlist_rend)[2] /* hashval*/;
  if (t48){
    ((cptr)srlist_self)[3] /* len*/ = 1;
    ((cptr)srlist_self)[2] /* hashval*/ = ((cptr)srlist_rstart)[2] /* hashval*/;
  };};};
  t1 = srlist_result;
  goto t1_label;
  t1_label: return t1;
}

cint srlist_reclaim(cint srlist_self){
  cint t49;
  object_Dec_ref(((cptr)srlist_self)[9] /* r_start*/);
  object_Dec_ref(((cptr)srlist_self)[10] /* r_end*/);
  object_Dec_ref(((cptr)srlist_self)[11] /* r_incr*/);
  object_Dec_ref(((cptr)srlist_self)[8] /* elem*/);
  list_reclaim((cint)srlist_self);
  t49_label: return t49;
}

cint srlist_Contains(cint srlist_self, cint srlist_ob){
  cint srlist_result;
  cint t50, t51, t52, t53, t54, t55, t56, t57, t58;
  t51 = ((cptr)srlist_ob)[4] /* class_of*/ != ((cptr)((cptr)srlist_self)[9] /* r_start*/)[4] /* class_of*/;
  if (t51){
    object_Dec_ref(srlist_self);
    object_Dec_ref(srlist_ob);
    t50 = boolean_False;
    goto t50_label;
  };
  t52 = ((cptr)((cptr)srlist_self)[9] /* r_start*/)[2] /* hashval*/ <= ((cptr)((cptr)srlist_self)[10] /* r_end*/)[2] /* hashval*/;
  if (t52){
    t53 = ((cptr)(((cptr)srlist_self)[0]))[192];
    t54 = ((f0)t53)((cint)srlist_self, (cint)srlist_ob, (cint)((cptr)srlist_self)[9] /* r_start*/, (cint)((cptr)srlist_self)[10] /* r_end*/, (cint)((cptr)srlist_self)[11] /* r_incr*/); /* Contained_in*/
    t50 = t54;
    goto t50_label;
  };
  t56 = ((cptr)(((cptr)srlist_self)[0]))[192];
  t57 = ((f0)t56)((cint)srlist_self, (cint)srlist_ob, (cint)((cptr)srlist_self)[10] /* r_end*/, (cint)((cptr)srlist_self)[9] /* r_start*/, (cint)((cptr)srlist_self)[11] /* r_incr*/); /* Contained_in*/
  t50 = t57;
  goto t50_label;
  t50_label: return t50;
}

cint srlist_Contained_in(cint srlist_self, cint srlist_ob, cint srlist_s, cint srlist_e, cint srlist_i){
  cint srlist_result;
  cint t59, t60, t61, t62, t63;
  srlist_result = boolean_True;
  t60 = ((cptr)srlist_ob)[2] /* hashval*/ < ((cptr)srlist_s)[2] /* hashval*/;
  if (t60){
    srlist_result = boolean_False;
  };
  t61 = ((cptr)srlist_ob)[2] /* hashval*/ > ((cptr)srlist_e)[2] /* hashval*/;
  if (t61){
    srlist_result = boolean_False;
  };
  t62 = ((cptr)srlist_ob)[2] /* hashval*/ - ((cptr)srlist_s)[2] /* hashval*/;
  t63 = cint_mod((cint)t62, (cint)((cptr)srlist_i)[2] /* hashval*/) != 0;
  if (t63){
    srlist_result = boolean_False;
  };
  object_Dec_ref(srlist_self);
  object_Dec_ref(srlist_ob);
  t59 = srlist_result;
  goto t59_label;
  t59_label: return t59;
}

cint srlist_lookup(cint srlist_self, cint srlist_i){
  cint srlist_result, srlist_j;
  cint t64, t65, t66, t67, t68, t69, t70, t71, t72, t73;
  t65 = srlist_i < 1;
  t66 = t65;
  if (!t66){    t67 = srlist_i > ((cptr)srlist_self)[3] /* len*/;
    t66 = t67;
  };
  if (t66){
    t64 = object_Undefined;
    goto t64_label;
  };
  t68 = srlist_i - 1;
  t69 = t68 * ((cptr)((cptr)srlist_self)[11] /* r_incr*/)[2] /* hashval*/;
  srlist_j = t69;
  t70 = ((cptr)((cptr)srlist_self)[9] /* r_start*/)[2] /* hashval*/ + srlist_j;
  t71 = ((cptr)(((cptr)((cptr)srlist_self)[8] /* elem*/)[0]))[109];
  t72 = ((f0)t71)((cint)((cptr)srlist_self)[8] /* elem*/, (cint)t70); /* update_hashval*/
  srlist_result = t72;
  ((cptr)srlist_self)[8] /* elem*/ = srlist_result;
  t64 = srlist_result;
  goto t64_label;
  t64_label: return t64;
}

cint srlist_Max(cint srlist_self, cint srlist_ob){
  cint srlist_result;
  cint t74, t75, t76, t77, t78, t79, t80;
  t75 = srlist_ob != object_Undefined;
  if (t75){
    t76 = collection_Max((cint)srlist_self, (cint)srlist_ob);
    t74 = t76;
    goto t74_label;
  };
  t77 = ((cptr)((cptr)srlist_self)[9] /* r_start*/)[2] /* hashval*/ >= ((cptr)((cptr)srlist_self)[10] /* r_end*/)[2] /* hashval*/;
  if (t77){
    srlist_result = ((cptr)srlist_self)[9] /* r_start*/;
  }else{
    t78 = ((cptr)(((cptr)srlist_self)[0]))[62];
    t79 = ((f0)t78)((cint)srlist_self, (cint)((cptr)srlist_self)[3] /* len*/); /* lookup*/
    srlist_result = t79;
  };
  object_Dec_ref(srlist_self);
  object_Dec_ref(srlist_ob);
  ((cptr)srlist_result)[1] += 1;
  t74 = srlist_result;
  goto t74_label;
  t74_label: return t74;
}

cint srlist_Min(cint srlist_self, cint srlist_ob){
  cint srlist_result;
  cint t81, t82, t83, t84, t85, t86, t87;
  t82 = srlist_ob != object_Undefined;
  if (t82){
    t83 = collection_Min((cint)srlist_self, (cint)srlist_ob);
    t81 = t83;
    goto t81_label;
  };
  t84 = ((cptr)((cptr)srlist_self)[9] /* r_start*/)[2] /* hashval*/ <= ((cptr)((cptr)srlist_self)[10] /* r_end*/)[2] /* hashval*/;
  if (t84){
    srlist_result = ((cptr)srlist_self)[9] /* r_start*/;
  }else{
    t85 = ((cptr)(((cptr)srlist_self)[0]))[62];
    t86 = ((f0)t85)((cint)srlist_self, (cint)((cptr)srlist_self)[3] /* len*/); /* lookup*/
    srlist_result = t86;
  };
  object_Dec_ref(srlist_self);
  object_Dec_ref(srlist_ob);
  ((cptr)srlist_result)[1] += 1;
  t81 = srlist_result;
  goto t81_label;
  t81_label: return t81;
}

cint srlist_ubstr(cint srlist_self){
  cint srlist_result;
  cint t88, t89, t90, t91, t92, t93, t94, t95, t96, t97, t98, t99, t100, t101, t102, t103, t104, t105, t106, t107, t108, t109, t110, t111;
  t89 = ((cptr)srlist_self)[3] /* len*/ < 100;
  if (t89){
    t90 = collection_ubstr((cint)srlist_self);
    t88 = t90;
    goto t88_label;
  };
  ((cptr)((cptr)srlist_self)[9] /* r_start*/)[1] += 1;
  t91 = ((cptr)(((cptr)((cptr)srlist_self)[9] /* r_start*/)[0]))[88];
  t92 = ((f0)t91)((cint)((cptr)srlist_self)[9] /* r_start*/); /* Mkstr*/
  ((cptr)strpool_str_44)[1] += 1;
  t94 = ((cptr)(((cptr)t92)[0]))[97];
  t95 = ((f0)t94)((cint)t92, (cint)strpool_str_44); /* Plus*/
  ((cptr)((cptr)srlist_self)[10] /* r_end*/)[1] += 1;
  t96 = ((cptr)(((cptr)((cptr)srlist_self)[10] /* r_end*/)[0]))[88];
  t97 = ((f0)t96)((cint)((cptr)srlist_self)[10] /* r_end*/); /* Mkstr*/
  t99 = ((cptr)(((cptr)t95)[0]))[97];
  t100 = ((f0)t99)((cint)t95, (cint)t97); /* Plus*/
  ((cptr)strpool_str_48)[1] += 1;
  t103 = ((cptr)(((cptr)t100)[0]))[97];
  t104 = ((f0)t103)((cint)t100, (cint)strpool_str_48); /* Plus*/
  ((cptr)((cptr)srlist_self)[11] /* r_incr*/)[1] += 1;
  t105 = ((cptr)(((cptr)((cptr)srlist_self)[11] /* r_incr*/)[0]))[88];
  t106 = ((f0)t105)((cint)((cptr)srlist_self)[11] /* r_incr*/); /* Mkstr*/
  t108 = ((cptr)(((cptr)t104)[0]))[97];
  t109 = ((f0)t108)((cint)t104, (cint)t106); /* Plus*/
  t88 = t109;
  goto t88_label;
  t88_label: return t88;
}

void init_srlist(){
  copy_meth_table(srlist_methods, list_methods);
  srlist_methods[0] = 48;
  srlist_methods[3] = srlist_alloc;
  srlist_methods[4] = srlist_reclaim;
  srlist_methods[20] = srlist_Contains;
  srlist_methods[192] = srlist_Contained_in;
  srlist_methods[62] = srlist_lookup;
  srlist_methods[80] = srlist_Max;
  srlist_methods[82] = srlist_Min;
  srlist_methods[112] = srlist_ubstr;
}
