#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr slicestr_methods[meth_max];
extern cptr integer_methods[meth_max];
extern cptr character_methods[meth_max];
extern cptr collection_methods[meth_max];
extern cptr list_methods[meth_max];
extern cptr slicelst_methods[meth_max];
extern cptr boolean_methods[meth_max];
extern cptr strpool_methods[meth_max];
extern cptr intset_methods[meth_max];
extern cptr charset_methods[meth_max];
extern cptr rset_methods[meth_max];
extern cptr slist_methods[meth_max];

extern cint strpool_str_5;
extern cint strpool_str_6;
extern cint boolean_True;
extern cint object_Undefined;
extern cint boolean_False;
extern cint intset_predef;
extern cint charset_predef;
extern cint strpool_str_30;
extern cint strpool_str_40;
extern cint strpool_str_43;
extern cint strpool_str_44;
extern cint strpool_str_38;
extern cint strpool_str_39;


cptr rlist_methods[meth_max];

cint rlist_alloc(cint rlist_self, cint rlist_rstart, cint rlist_rend){
  cint rlist_result;
  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;
  t2 = list_alloc((cint)rlist_self);
  rlist_result = t2;
  t3 = ((cptr)rlist_rstart)[4] /* class_of*/ == strpool_str_5;
  t4 = t3;
  if (t4){
    t5 = ((cptr)rlist_rend)[4] /* class_of*/ == strpool_str_5;
    t4 = t5;
  };
  if (t4){
    ((cptr)intset_predef)[1] += 1;
    ((cptr)rlist_self)[7] /* elemtype*/ = intset_predef;
    t6 = mem_malloc(28); ((cptr)t6)[0] = integer_methods;
    t7 = integer_ialloc((cint)t6, (cint)0);
    ((cptr)rlist_self)[8] /* elem*/ = t7;
  }else{
  t8 = ((cptr)rlist_rstart)[4] /* class_of*/ == strpool_str_6;
  t9 = t8;
  if (t9){
    t10 = ((cptr)rlist_rstart)[3] /* len*/ == 1;
    t9 = t10;
  };
  t11 = t9;
  if (t11){
    t12 = ((cptr)rlist_rend)[4] /* class_of*/ == strpool_str_6;
    t11 = t12;
  };
  t13 = t11;
  if (t13){
    t14 = ((cptr)rlist_rend)[3] /* len*/ == 1;
    t13 = t14;
  };
  if (t13){
    ((cptr)charset_predef)[1] += 1;
    ((cptr)rlist_self)[7] /* elemtype*/ = charset_predef;
    t15 = mem_malloc(36); ((cptr)t15)[0] = character_methods;
    t16 = character_alloc((cint)t15, (cint)0, (cint)0);
    ((cptr)rlist_self)[8] /* elem*/ = t16;
  }else{
    object_Dec_ref(rlist_rstart);
    object_Dec_ref(rlist_rend);
    list_reclaim((cint)rlist_self);
    t1 = object_Undefined;
    goto t1_label;
  };};
  ((cptr)rlist_self)[5] /* representation*/ = strpool_str_43;
  ((cptr)rlist_self)[9] /* r_start*/ = rlist_rstart;
  ((cptr)rlist_self)[10] /* r_end*/ = rlist_rend;
  t17 = ((cptr)rlist_rstart)[2] /* hashval*/ <= ((cptr)rlist_rend)[2] /* hashval*/;
  if (t17){
    t18 = ((cptr)rlist_rstart)[2] /* hashval*/ - 1;
    t19 = ((cptr)rlist_rend)[2] /* hashval*/ - t18;
    ((cptr)rlist_self)[3] /* len*/ = t19;
    t20 = ((cptr)rlist_self)[3] /* len*/ <= 0;
    if (t20){
      ((cptr)rlist_self)[3] /* len*/ = -1;
    };
    t21 = ((cptr)rlist_rstart)[2] /* hashval*/ - 1;
    t22 = ((cptr)rlist_self)[3] /* len*/ * t21;
    t23 = ((cptr)rlist_self)[3] /* len*/ + 1;
    t24 = t23 * ((cptr)rlist_self)[3] /* len*/;
    t25 = t24 / 2;
    t26 = t22 + t25;
    ((cptr)rlist_self)[2] /* hashval*/ = t26;
  }else{
    ((cptr)rlist_self)[3] /* len*/ = 0;
    ((cptr)rlist_self)[2] /* hashval*/ = 0;
  };
  t1 = rlist_result;
  goto t1_label;
  t1_label: return t1;
}

cint rlist_reclaim(cint rlist_self){
  cint t27;
  object_Dec_ref(((cptr)rlist_self)[9] /* r_start*/);
  object_Dec_ref(((cptr)rlist_self)[10] /* r_end*/);
  object_Dec_ref(((cptr)rlist_self)[8] /* elem*/);
  list_reclaim((cint)rlist_self);
  t27_label: return t27;
}

cint rlist_All_but_last(cint rlist_self){
  cint rlist_result, rlist_sv, rlist_fv;
  cint t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46;
  t29 = ((cptr)rlist_self)[3] /* len*/ == 1;
  if (t29){
    object_Dec_ref(rlist_self);
    t30 = mem_malloc(40); ((cptr)t30)[0] = slist_methods;
    t31 = slist_alloc((cint)t30, (cint)0);
    t28 = t31;
    goto t28_label;
  }else{
  t32 = ((cptr)rlist_self)[3] /* len*/ == 0;
  if (t32){
    object_Dec_ref(rlist_self);
    t28 = object_Undefined;
    goto t28_label;
  }else{
  t33 = ((cptr)rlist_self)[1] /* refcount*/ == 1;
  if (t33){
    t34 = ((cptr)rlist_self)[2] /* hashval*/ - ((cptr)((cptr)rlist_self)[10] /* r_end*/)[2] /* hashval*/;
    ((cptr)rlist_self)[2] /* hashval*/ = t34;
    t35 = ((cptr)rlist_self)[3] /* len*/ > 1;
    if (t35){
      t36 = ((cptr)rlist_self)[3] /* len*/ - 1;
      ((cptr)rlist_self)[3] /* len*/ = t36;
    };
    t37 = ((cptr)((cptr)rlist_self)[10] /* r_end*/)[2] /* hashval*/ - 1;
    t38 = ((cptr)(((cptr)((cptr)rlist_self)[10] /* r_end*/)[0]))[109];
    t39 = ((f0)t38)((cint)((cptr)rlist_self)[10] /* r_end*/, (cint)t37); /* update_hashval*/
    ((cptr)rlist_self)[10] /* r_end*/ = t39;
    t28 = rlist_self;
    goto t28_label;
  }else{
    ((cptr)((cptr)rlist_self)[9] /* r_start*/)[1] += 1;
    rlist_sv = ((cptr)rlist_self)[9] /* r_start*/;
    ((cptr)((cptr)rlist_self)[10] /* r_end*/)[1] += 1;
    t41 = ((cptr)((cptr)rlist_self)[10] /* r_end*/)[2] /* hashval*/ - 1;
    t42 = ((cptr)(((cptr)((cptr)rlist_self)[10] /* r_end*/)[0]))[109];
    t43 = ((f0)t42)((cint)((cptr)rlist_self)[10] /* r_end*/, (cint)t41); /* update_hashval*/
    rlist_fv = t43;
    object_Dec_ref(rlist_self);
    t45 = mem_malloc(44); ((cptr)t45)[0] = rlist_methods;
    t46 = rlist_alloc((cint)t45, (cint)rlist_sv, (cint)rlist_fv);
    t28 = t46;
    goto t28_label;
  };};};
  t28 = rlist_result;
  goto t28_label;
  t28_label: return t28;
}

cint rlist_Ascending(cint rlist_self){
  cint rlist_result;
  cint t47;
  object_Dec_ref(rlist_self);
  t47 = boolean_True;
  goto t47_label;
  t47_label: return t47;
}

cint rlist_Contains(cint rlist_self, cint rlist_ob){
  cint rlist_result;
  cint t48, t49, t50, t51, t52, t53, t54, t55;
  t49 = ((cptr)rlist_ob)[4] /* class_of*/ != ((cptr)((cptr)rlist_self)[9] /* r_start*/)[4] /* class_of*/;
  if (t49){
    object_Dec_ref(rlist_self);
    object_Dec_ref(rlist_ob);
    t48 = boolean_False;
    goto t48_label;
  };
  t50 = ((cptr)(((cptr)rlist_ob)[0]))[60];
  t51 = ((f0)t50)((cint)rlist_ob, (cint)((cptr)rlist_self)[9] /* r_start*/); /* less_than*/
  t52 = t51 == 1;
  if (t52){
    t48 = boolean_False;
    goto t48_label;
  };
  t53 = ((cptr)(((cptr)((cptr)rlist_self)[10] /* r_end*/)[0]))[60];
  t54 = ((f0)t53)((cint)((cptr)rlist_self)[10] /* r_end*/, (cint)rlist_ob); /* less_than*/
  t55 = t54 == 1;
  if (t55){
    t48 = boolean_False;
    goto t48_label;
  };
  t48 = boolean_True;
  goto t48_label;
  t48_label: return t48;
}

cint rlist_Descending(cint rlist_self){
  cint rlist_result;
  cint t56;
  object_Dec_ref(rlist_self);
  t56 = boolean_False;
  goto t56_label;
  t56_label: return t56;
}

cint rlist_lookup(cint rlist_self, cint rlist_i){
  cint rlist_result;
  cint t57, t58, t59, t60, t61, t62, t63, t64, t65;
  t58 = rlist_i < 1;
  t59 = t58;
  if (!t59){    t60 = rlist_i > ((cptr)rlist_self)[3] /* len*/;
    t59 = t60;
  };
  if (t59){
    t57 = object_Undefined;
    goto t57_label;
  };
  t61 = ((cptr)((cptr)rlist_self)[9] /* r_start*/)[2] /* hashval*/ + rlist_i;
  t62 = t61 - 1;
  t63 = ((cptr)(((cptr)((cptr)rlist_self)[8] /* elem*/)[0]))[109];
  t64 = ((f0)t63)((cint)((cptr)rlist_self)[8] /* elem*/, (cint)t62); /* update_hashval*/
  rlist_result = t64;
  ((cptr)rlist_self)[8] /* elem*/ = rlist_result;
  t57 = rlist_result;
  goto t57_label;
  t57_label: return t57;
}

cint rlist_Make_set(cint rlist_self){
  cint rlist_result;
  cint t66, t67, t68;
  t67 = mem_malloc(44); ((cptr)t67)[0] = rset_methods;
  ((cptr)((cptr)rlist_self)[9] /* r_start*/)[1] += 1;
  ((cptr)((cptr)rlist_self)[10] /* r_end*/)[1] += 1;
  t68 = rset_alloc((cint)t67, (cint)((cptr)rlist_self)[9] /* r_start*/, (cint)((cptr)rlist_self)[10] /* r_end*/);
  rlist_result = t68;
  object_Dec_ref(rlist_self);
  t66 = rlist_result;
  goto t66_label;
  t66_label: return t66;
}

cint rlist_Mapped(cint rlist_self, cint rlist_ob){
  cint rlist_result, rlist_i, rlist_j;
  cint t69, t70, t71, t72, t73, t74, t75, t76, t77, t78, t79, t80, t81, t82;
  rlist_i = ((cptr)((cptr)rlist_self)[9] /* r_start*/)[2] /* hashval*/;
  rlist_j = ((cptr)((cptr)rlist_self)[10] /* r_end*/)[2] /* hashval*/;
  t70 = rlist_j > ((cptr)rlist_ob)[3] /* len*/;
  if (t70){
    rlist_j = ((cptr)rlist_ob)[3] /* len*/;
  };
  t71 = ((cptr)rlist_self)[7] /* elemtype*/ == intset_predef;
  t72 = t71;
  if (t72){
    t73 = 1 <= rlist_i;
    t72 = t73;
  };
  t74 = t72;
  if (t74){
    t75 = rlist_i <= rlist_j;
    t74 = t75;
  };
  if (t74){
    t76 = ((cptr)rlist_ob)[4] /* class_of*/ == strpool_str_30;
    if (t76){
      object_Dec_ref(rlist_self);
      t77 = mem_malloc(40); ((cptr)t77)[0] = slicelst_methods;
      t78 = slicelst_alloc((cint)t77, (cint)rlist_ob, (cint)rlist_i, (cint)rlist_j);
      t69 = t78;
      goto t69_label;
    }else{
    t79 = ((cptr)rlist_ob)[4] /* class_of*/ == strpool_str_6;
    if (t79){
      object_Dec_ref(rlist_self);
      t80 = mem_malloc(48); ((cptr)t80)[0] = slicestr_methods;
      t81 = slicestr_alloc((cint)t80, (cint)rlist_ob, (cint)rlist_i, (cint)rlist_j);
      t69 = t81;
      goto t69_label;
    };};
  };
  t82 = collection_Mapped((cint)rlist_self, (cint)rlist_ob);
  t69 = t82;
  goto t69_label;
  t69_label: return t69;
}

cint rlist_Max(cint rlist_self, cint rlist_ob){
  cint rlist_result;
  cint t83, t84, t85, t86;
  t84 = rlist_ob != object_Undefined;
  if (t84){
    t85 = collection_Max((cint)rlist_self, (cint)rlist_ob);
    t83 = t85;
    goto t83_label;
  };
  rlist_result = ((cptr)rlist_self)[10] /* r_end*/;
  t86 = ((cptr)rlist_result)[2] /* hashval*/ < ((cptr)((cptr)rlist_self)[9] /* r_start*/)[2] /* hashval*/;
  if (t86){
    rlist_result = ((cptr)rlist_self)[9] /* r_start*/;
  };
  object_Dec_ref(rlist_self);
  object_Dec_ref(rlist_ob);
  ((cptr)rlist_result)[1] += 1;
  t83 = rlist_result;
  goto t83_label;
  t83_label: return t83;
}

cint rlist_Min(cint rlist_self, cint rlist_ob){
  cint rlist_result;
  cint t87, t88, t89, t90;
  t88 = rlist_ob != object_Undefined;
  if (t88){
    t89 = collection_Min((cint)rlist_self, (cint)rlist_ob);
    t87 = t89;
    goto t87_label;
  };
  rlist_result = ((cptr)rlist_self)[9] /* r_start*/;
  t90 = ((cptr)rlist_result)[2] /* hashval*/ > ((cptr)((cptr)rlist_self)[9] /* r_start*/)[2] /* hashval*/;
  if (t90){
    rlist_result = ((cptr)rlist_self)[10] /* r_end*/;
  };
  object_Dec_ref(rlist_self);
  object_Dec_ref(rlist_ob);
  ((cptr)rlist_result)[1] += 1;
  t87 = rlist_result;
  goto t87_label;
  t87_label: return t87;
}

cint rlist_Mkstr(cint rlist_self){
  cint rlist_result;
  cint t91, t92, t93, t94, t95, t96, t97, t98, t99, t100, t101;
  t92 = ((cptr)rlist_self)[3] /* len*/ == 0;
  if (t92){
    ((cptr)strpool_str_38)[1] += 1;
    rlist_result = strpool_str_38;
  }else{
    ((cptr)strpool_str_39)[1] += 1;
    t93 = ((cptr)(((cptr)rlist_self)[0]))[112];
    t94 = ((f0)t93)((cint)rlist_self); /* ubstr*/
    t95 = ((cptr)(((cptr)strpool_str_39)[0]))[97];
    t96 = ((f0)t95)((cint)strpool_str_39, (cint)t94); /* Plus*/
    ((cptr)strpool_str_40)[1] += 1;
    t99 = ((cptr)(((cptr)t96)[0]))[97];
    t100 = ((f0)t99)((cint)t96, (cint)strpool_str_40); /* Plus*/
    rlist_result = t100;
  };
  object_Dec_ref(rlist_self);
  t91 = rlist_result;
  goto t91_label;
  t91_label: return t91;
}

cint rlist_Tail(cint rlist_self){
  cint rlist_result, rlist_sv, rlist_fv;
  cint t102, t103, t104, t105, t106, t107, t108, t109, t110, t111, t112, t113, t114, t115, t116, t117, t118, t119, t120;
  t103 = ((cptr)rlist_self)[3] /* len*/ == 1;
  if (t103){
    object_Dec_ref(rlist_self);
    t104 = mem_malloc(40); ((cptr)t104)[0] = slist_methods;
    t105 = slist_alloc((cint)t104, (cint)0);
    t102 = t105;
    goto t102_label;
  }else{
  t106 = ((cptr)rlist_self)[3] /* len*/ == 0;
  if (t106){
    object_Dec_ref(rlist_self);
    t102 = object_Undefined;
    goto t102_label;
  }else{
  t107 = ((cptr)rlist_self)[1] /* refcount*/ == 1;
  if (t107){
    t108 = ((cptr)rlist_self)[2] /* hashval*/ - ((cptr)((cptr)rlist_self)[9] /* r_start*/)[2] /* hashval*/;
    ((cptr)rlist_self)[2] /* hashval*/ = t108;
    t109 = ((cptr)rlist_self)[3] /* len*/ > 1;
    if (t109){
      t110 = ((cptr)rlist_self)[3] /* len*/ - 1;
      ((cptr)rlist_self)[3] /* len*/ = t110;
    };
    t111 = ((cptr)((cptr)rlist_self)[9] /* r_start*/)[2] /* hashval*/ + 1;
    t112 = ((cptr)(((cptr)((cptr)rlist_self)[9] /* r_start*/)[0]))[109];
    t113 = ((f0)t112)((cint)((cptr)rlist_self)[9] /* r_start*/, (cint)t111); /* update_hashval*/
    ((cptr)rlist_self)[9] /* r_start*/ = t113;
    t102 = rlist_self;
    goto t102_label;
  }else{
    ((cptr)((cptr)rlist_self)[9] /* r_start*/)[1] += 1;
    t115 = ((cptr)((cptr)rlist_self)[9] /* r_start*/)[2] /* hashval*/ + 1;
    t116 = ((cptr)(((cptr)((cptr)rlist_self)[9] /* r_start*/)[0]))[109];
    t117 = ((f0)t116)((cint)((cptr)rlist_self)[9] /* r_start*/, (cint)t115); /* update_hashval*/
    rlist_sv = t117;
    ((cptr)((cptr)rlist_self)[10] /* r_end*/)[1] += 1;
    rlist_fv = ((cptr)rlist_self)[10] /* r_end*/;
    object_Dec_ref(rlist_self);
    t119 = mem_malloc(44); ((cptr)t119)[0] = rlist_methods;
    t120 = rlist_alloc((cint)t119, (cint)rlist_sv, (cint)rlist_fv);
    t102 = t120;
    goto t102_label;
  };};};
  t102 = rlist_result;
  goto t102_label;
  t102_label: return t102;
}

cint rlist_ubstr(cint rlist_self){
  cint rlist_result;
  cint t121, t122, t123, t124, t125, t126, t127, t128, t129, t130, t131, t132, t133, t134, t135, t136, t137;
  t122 = ((cptr)rlist_self)[3] /* len*/ > 0;
  t123 = t122;
  if (t123){
    t124 = ((cptr)rlist_self)[3] /* len*/ < 100;
    t123 = t124;
  };
  if (t123){
    t125 = collection_ubstr((cint)rlist_self);
    t121 = t125;
    goto t121_label;
  };
  ((cptr)((cptr)rlist_self)[9] /* r_start*/)[1] += 1;
  t126 = ((cptr)(((cptr)((cptr)rlist_self)[9] /* r_start*/)[0]))[88];
  t127 = ((f0)t126)((cint)((cptr)rlist_self)[9] /* r_start*/); /* Mkstr*/
  ((cptr)strpool_str_44)[1] += 1;
  t129 = ((cptr)(((cptr)t127)[0]))[97];
  t130 = ((f0)t129)((cint)t127, (cint)strpool_str_44); /* Plus*/
  ((cptr)((cptr)rlist_self)[10] /* r_end*/)[1] += 1;
  t131 = ((cptr)(((cptr)((cptr)rlist_self)[10] /* r_end*/)[0]))[88];
  t132 = ((f0)t131)((cint)((cptr)rlist_self)[10] /* r_end*/); /* Mkstr*/
  t134 = ((cptr)(((cptr)t130)[0]))[97];
  t135 = ((f0)t134)((cint)t130, (cint)t132); /* Plus*/
  t121 = t135;
  goto t121_label;
  t121_label: return t121;
}

void init_rlist(){
  copy_meth_table(rlist_methods, list_methods);
  rlist_methods[0] = 44;
  rlist_methods[3] = rlist_alloc;
  rlist_methods[4] = rlist_reclaim;
  rlist_methods[6] = rlist_All_but_last;
  rlist_methods[11] = rlist_Ascending;
  rlist_methods[20] = rlist_Contains;
  rlist_methods[30] = rlist_Descending;
  rlist_methods[62] = rlist_lookup;
  rlist_methods[74] = rlist_Make_set;
  rlist_methods[79] = rlist_Mapped;
  rlist_methods[80] = rlist_Max;
  rlist_methods[82] = rlist_Min;
  rlist_methods[88] = rlist_Mkstr;
  rlist_methods[106] = rlist_Tail;
  rlist_methods[112] = rlist_ubstr;
}
