#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr collection_methods[meth_max];
extern cptr boolean_methods[meth_max];
extern cptr string_methods[meth_max];
extern cptr integer_methods[meth_max];
extern cptr set_methods[meth_max];
#include "cint.h"
extern cptr strpool_methods[meth_max];
extern cptr slicelst_methods[meth_max];
extern cptr slist_methods[meth_max];
extern cptr plist_methods[meth_max];
extern cptr sset_methods[meth_max];
extern cptr ulist_methods[meth_max];

extern cint boolean_True;
extern cint strpool_str_5;
extern cint object_Undefined;
extern cint boolean_False;
extern cint strpool_str_30;
extern cint strpool_str_40;
extern cint strpool_str_38;
extern cint strpool_str_39;


cptr list_methods[meth_max];

cint list_alloc(cint list_self){
  cint list_result;
  cint t1, t2;
  t2 = collection_alloc((cint)list_self);
  list_result = t2;
  ((cptr)list_self)[4] /* class_of*/ = strpool_str_30;
  t1 = list_result;
  goto t1_label;
  t1_label: return t1;
}

cint list_reclaim(cint list_self){
  cint t3;
  collection_reclaim((cint)list_self);
  t3_label: return t3;
}

cint list_All_but_last(cint list_self){
  cint list_result;
  cint t4, t5, t6, t7, t8, t9, t10, t11;
  t5 = ((cptr)list_self)[3] /* len*/ <= 0;
  if (t5){
    object_Dec_ref(list_self);
    t4 = object_Undefined;
    goto t4_label;
  };
  t6 = ((cptr)list_self)[3] /* len*/ == 1;
  if (t6){
    object_Dec_ref(list_self);
    t7 = mem_malloc(40); ((cptr)t7)[0] = slist_methods;
    t8 = slist_alloc((cint)t7, (cint)1);
    t4 = t8;
    goto t4_label;
  };
  t9 = mem_malloc(40); ((cptr)t9)[0] = slicelst_methods;
  t10 = ((cptr)list_self)[3] /* len*/ - 1;
  t11 = slicelst_alloc((cint)t9, (cint)list_self, (cint)1, (cint)t10);
  t4 = t11;
  goto t4_label;
  t4_label: return t4;
}

cint list_Ascending(cint list_self){
  cint list_result, list_i;
  cint t12, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33;
  list_result = boolean_True;
  t14 = ((cptr)list_self)[3] /* len*/ - 1;
  for (list_i = 1; list_i <= t14; list_i++){
    t15 = ((cptr)(((cptr)list_self)[0]))[62];
    t16 = ((f0)t15)((cint)list_self, (cint)list_i); /* lookup*/
    t17 = list_i + 1;
    t18 = ((cptr)(((cptr)list_self)[0]))[62];
    t19 = ((f0)t18)((cint)list_self, (cint)t17); /* lookup*/
    t21 = ((cptr)(((cptr)t16)[0]))[60];
    t22 = ((f0)t21)((cint)t16, (cint)t19); /* less_than*/
    t31 = t22 == 0;
    t32 = t31;
    if (t32){
    t23 = ((cptr)(((cptr)list_self)[0]))[62];
    t24 = ((f0)t23)((cint)list_self, (cint)list_i); /* lookup*/
    t25 = list_i + 1;
    t26 = ((cptr)(((cptr)list_self)[0]))[62];
    t27 = ((f0)t26)((cint)list_self, (cint)t25); /* lookup*/
    t29 = ((cptr)(((cptr)t24)[0]))[37];
    t30 = ((f0)t29)((cint)t24, (cint)t27); /* equal*/
      t33 = t30 == 0;
      t32 = t33;
    };
    if (t32){
      t12 = boolean_False;
      goto t12_label;
    };
  };t13:;
  t12 = list_result;
  goto t12_label;
  t12_label: return t12;
}

cint list_Assign_to_component(cint list_self, cint list_param, cint list_new_val, cint list_op){
  cint list_result;
  cint t34, t35, t36, t37, t38, t39, t40, t41, t42, t43;
  t35 = ((cptr)list_param)[4] /* class_of*/ == strpool_str_5;
  t36 = t35;
  if (t36){
    t37 = ((cptr)list_param)[2] /* hashval*/ > 0;
    t36 = t37;
  };
  if (t36){
    t38 = ((cptr)(((cptr)list_self)[0]))[130];
    t39 = ((f0)t38)((cint)list_self, (cint)((cptr)list_param)[2] /* hashval*/, (cint)list_new_val, (cint)list_op); /* update*/
    list_result = t39;
    object_Dec_ref(list_param);
  }else{
    t41 = ((cptr)(((cptr)list_self)[0]))[21];
    t42 = ((f0)t41)((cint)list_self); /* copy_of*/
    list_result = t42;
    object_Dec_ref(list_param);
    object_Dec_ref(list_new_val);
  };
  t34 = list_result;
  goto t34_label;
  t34_label: return t34;
}

cint list_Delete_ith(cint list_self, cint list_i){
  cint list_result, list_sl1, list_sl2;
  cint t44, t45, t46, t47, t48, t49, t50, t51, t52, t53, t54, t55, t56, t57, t58, t59, t60;
  t45 = list_i == 1;
  if (t45){
    t46 = mem_malloc(40); ((cptr)t46)[0] = slicelst_methods;
    t47 = slicelst_alloc((cint)t46, (cint)list_self, (cint)2, (cint)((cptr)list_self)[3] /* len*/);
    t44 = t47;
    goto t44_label;
  }else{
  t48 = list_i == ((cptr)list_self)[3] /* len*/;
  if (t48){
    t49 = mem_malloc(40); ((cptr)t49)[0] = slicelst_methods;
    t50 = list_i - 1;
    t51 = slicelst_alloc((cint)t49, (cint)list_self, (cint)1, (cint)t50);
    t44 = t51;
    goto t44_label;
  }else{
    t52 = mem_malloc(40); ((cptr)t52)[0] = slicelst_methods;
    t53 = list_i - 1;
    t54 = slicelst_alloc((cint)t52, (cint)list_self, (cint)1, (cint)t53);
    list_sl1 = t54;
    t55 = mem_malloc(40); ((cptr)t55)[0] = slicelst_methods;
    ((cptr)list_self)[1] += 1;
    t56 = list_i + 1;
    t57 = slicelst_alloc((cint)t55, (cint)list_self, (cint)t56, (cint)((cptr)list_self)[3] /* len*/);
    list_sl2 = t57;
    t58 = ((cptr)(((cptr)list_sl1)[0]))[97];
    t59 = ((f0)t58)((cint)list_sl1, (cint)list_sl2); /* Plus*/
    t44 = t59;
    goto t44_label;
  };};
  t44 = list_result;
  goto t44_label;
  t44_label: return t44;
}

cint list_Descending(cint list_self){
  cint list_result, list_i;
  cint t61, t63, t64, t65, t66, t67, t68, t69, t70, t71, t72;
  list_result = boolean_True;
  t63 = ((cptr)list_self)[3] /* len*/ - 1;
  for (list_i = 1; list_i <= t63; list_i++){
    t64 = ((cptr)(((cptr)list_self)[0]))[62];
    t65 = ((f0)t64)((cint)list_self, (cint)list_i); /* lookup*/
    t66 = list_i + 1;
    t67 = ((cptr)(((cptr)list_self)[0]))[62];
    t68 = ((f0)t67)((cint)list_self, (cint)t66); /* lookup*/
    t70 = ((cptr)(((cptr)t65)[0]))[60];
    t71 = ((f0)t70)((cint)t65, (cint)t68); /* less_than*/
    t72 = t71 == 1;
    if (t72){
      t61 = boolean_False;
      goto t61_label;
    };
  };t62:;
  t61 = list_result;
  goto t61_label;
  t61_label: return t61;
}

cint list_equal(cint list_self, cint list_other){
  cint list_result, list_i;
  cint t73, t74, t75, t76, t77, t79, t80, t81, t82, t83, t84, t85, t86;
  t74 = list_self == list_other;
  if (t74){
    t73 = 1;
    goto t73_label;
  };
  t75 = ((cptr)list_self)[2] /* hashval*/ != ((cptr)list_other)[2] /* hashval*/;
  if (t75){
    t73 = 0;
    goto t73_label;
  };
  t76 = ((cptr)list_self)[3] /* len*/ != ((cptr)list_other)[3] /* len*/;
  if (t76){
    t73 = 0;
    goto t73_label;
  };
  t77 = ((cptr)list_other)[4] /* class_of*/ != strpool_str_30;
  if (t77){
    t73 = 0;
    goto t73_label;
  };
  for (list_i = 1; list_i <= ((cptr)list_self)[3] /* len*/; list_i++){
    t79 = ((cptr)(((cptr)list_self)[0]))[62];
    t80 = ((f0)t79)((cint)list_self, (cint)list_i); /* lookup*/
    t81 = ((cptr)(((cptr)list_other)[0]))[62];
    t82 = ((f0)t81)((cint)list_other, (cint)list_i); /* lookup*/
    t84 = ((cptr)(((cptr)t80)[0]))[37];
    t85 = ((f0)t84)((cint)t80, (cint)t82); /* equal*/
    t86 = t85 == 0;
    if (t86){
      t73 = 0;
      goto t73_label;
    };
  };t78:;
  t73 = 1;
  goto t73_label;
  t73_label: return t73;
}

cint list_less_than(cint list_self, cint list_other){
  cint list_result, list_o1, list_o2, list_i, list_j;
  cint t87, t88, t89, t91, t92, t93, t94, t95, t96, t97, t98, t99, t100, t101, t102, t103;
  t88 = ((cptr)list_other)[4] /* class_of*/ != strpool_str_30;
  if (t88){
    t87 = 0;
    goto t87_label;
  };
  list_i = ((cptr)list_self)[3] /* len*/;
  t89 = list_i > ((cptr)list_other)[3] /* len*/;
  if (t89){
    list_i = ((cptr)list_other)[3] /* len*/;
  };
  for (list_j = 1; list_j <= list_i; list_j++){
    t91 = ((cptr)(((cptr)list_self)[0]))[62];
    t92 = ((f0)t91)((cint)list_self, (cint)list_j); /* lookup*/
    list_o1 = t92;
    t94 = ((cptr)(((cptr)list_other)[0]))[62];
    t95 = ((f0)t94)((cint)list_other, (cint)list_j); /* lookup*/
    list_o2 = t95;
    t97 = ((cptr)(((cptr)list_o1)[0]))[60];
    t98 = ((f0)t97)((cint)list_o1, (cint)list_o2); /* less_than*/
    t99 = t98 == 1;
    if (t99){
      t87 = 1;
      goto t87_label;
    };
    t100 = ((cptr)(((cptr)list_o2)[0]))[60];
    t101 = ((f0)t100)((cint)list_o2, (cint)list_o1); /* less_than*/
    t102 = t101 == 1;
    if (t102){
      t87 = 0;
      goto t87_label;
    };
  };t90:;
  t103 = list_i < ((cptr)list_other)[3] /* len*/;
  if (t103){
    t87 = 1;
    goto t87_label;
  };
  t87 = 0;
  goto t87_label;
  t87_label: return t87;
}

cint list_Make_list(cint list_self){
  cint list_result;
  cint t104;
  t104 = list_self;
  goto t104_label;
  t104_label: return t104;
}

cint list_Mkstr(cint list_self){
  cint list_result, list_elem;
  cint t105, t106, t107, t108, t109, t110, t111, t112, t113, t114, t115;
  t106 = ((cptr)list_self)[3] /* len*/ < 1;
  if (t106){
    object_Dec_ref(list_self);
    ((cptr)strpool_str_38)[1] += 1;
    t105 = strpool_str_38;
    goto t105_label;
  };
  ((cptr)strpool_str_39)[1] += 1;
  t107 = ((cptr)(((cptr)list_self)[0]))[112];
  t108 = ((f0)t107)((cint)list_self); /* ubstr*/
  t109 = ((cptr)(((cptr)strpool_str_39)[0]))[97];
  t110 = ((f0)t109)((cint)strpool_str_39, (cint)t108); /* Plus*/
  ((cptr)strpool_str_40)[1] += 1;
  t113 = ((cptr)(((cptr)t110)[0]))[97];
  t114 = ((f0)t113)((cint)t110, (cint)strpool_str_40); /* Plus*/
  list_result = t114;
  object_Dec_ref(list_self);
  t105 = list_result;
  goto t105_label;
  t105_label: return t105;
}

cint list_Plus(cint list_self, cint list_ob){
  cint list_result;
  cint t116, t117, t118, t119, t120;
  t117 = ((cptr)list_ob)[4] /* class_of*/ == strpool_str_30;
  if (t117){
    t118 = ((cptr)list_self)[3] /* len*/ > 0;
    if (t118){
      t119 = mem_malloc(40); ((cptr)t119)[0] = plist_methods;
      t120 = plist_alloc((cint)t119, (cint)list_self, (cint)list_ob);
      t116 = t120;
      goto t116_label;
    };
    object_Dec_ref(list_self);
    t116 = list_ob;
    goto t116_label;
  };
  object_Dec_ref(list_self);
  object_Dec_ref(list_ob);
  t116 = object_Undefined;
  goto t116_label;
  t116_label: return t116;
}

cint list_Tail(cint list_self){
  cint list_result;
  cint t121, t122, t123, t124, t125, t126, t127;
  t122 = ((cptr)list_self)[3] /* len*/ <= 0;
  if (t122){
    object_Dec_ref(list_self);
    t121 = object_Undefined;
    goto t121_label;
  };
  t123 = ((cptr)list_self)[3] /* len*/ == 1;
  if (t123){
    object_Dec_ref(list_self);
    t124 = mem_malloc(40); ((cptr)t124)[0] = slist_methods;
    t125 = slist_alloc((cint)t124, (cint)1);
    t121 = t125;
    goto t121_label;
  };
  t126 = mem_malloc(40); ((cptr)t126)[0] = slicelst_methods;
  t127 = slicelst_alloc((cint)t126, (cint)list_self, (cint)2, (cint)((cptr)list_self)[3] /* len*/);
  t121 = t127;
  goto t121_label;
  t121_label: return t121;
}

cint list_update(cint list_self, cint list_i, cint list_ob, cint list_op){
  cint list_result, list_oldob, list_oblst, list_sl, list_sl1, list_sl2, list_ulst;
  cint t128, t129, t130, t131, t132, t133, t134, t135, t136, t137, t138, t139, t140, t141, t142, t143, t144, t145, t146, t147, t148, t149, t150, t151, t152, t153, t154, t155, t156, t157, t158, t159, t160, t161, t162, t163, t164, t165, t166, t167, t168, t169, t170, t171, t172, t173, t174, t175, t176, t177, t178, t179, t180, t181, t182, t183, t184, t185, t186, t187, t188, t189, t190, t191, t192, t193, t194, t195, t196, t197, t198, t199, t200, t201, t202, t203;
  t131 = ((cptr)(((cptr)list_self)[0]))[62];
  t130 = ((f0)t131)((cint)list_self, (cint)list_i); /* lookup*/
  ((cptr)t130)[1] += 1;
  list_oldob = t130;
  t132 = list_op == 0;
  if (t132){
    object_Dec_ref(list_oldob);
  };
  t133 = list_op == 1;
  if (t133){
    t134 = ((cptr)(((cptr)list_oldob)[0]))[31];
    t135 = ((f0)t134)((cint)list_oldob, (cint)list_ob); /* Divide*/
    list_ob = t135;
  };
  t137 = list_op == 2;
  if (t137){
    t138 = ((cptr)(((cptr)list_oldob)[0]))[83];
    t139 = ((f0)t138)((cint)list_oldob, (cint)list_ob); /* Minus*/
    list_ob = t139;
  };
  t141 = list_op == 3;
  if (t141){
    t142 = ((cptr)(((cptr)list_oldob)[0]))[89];
    t143 = ((f0)t142)((cint)list_oldob, (cint)list_ob); /* Multiply*/
    list_ob = t143;
  };
  t145 = list_op == 4;
  if (t145){
    t146 = ((cptr)(((cptr)list_oldob)[0]))[97];
    t147 = ((f0)t146)((cint)list_oldob, (cint)list_ob); /* Plus*/
    list_ob = t147;
  };
  t149 = list_op == 5;
  if (t149){
    t150 = ((cptr)(((cptr)list_oldob)[0]))[7];
    t151 = ((f0)t150)((cint)list_oldob, (cint)list_ob); /* Append*/
    list_ob = t151;
  };
  t153 = mem_malloc(40); ((cptr)t153)[0] = slist_methods;
  t154 = slist_alloc((cint)t153, (cint)1);
  t155 = ((cptr)(((cptr)t154)[0]))[7];
  t156 = ((f0)t155)((cint)t154, (cint)list_ob); /* Append*/
  list_oblst = t156;
  t158 = list_i == 1;
  t159 = t158;
  if (t159){
    t160 = ((cptr)list_self)[3] /* len*/ == 1;
    t159 = t160;
  };
  if (t159){
    object_Dec_ref(list_self);
    t128 = list_oblst;
    goto t128_label;
  }else{
  t161 = list_i == 1;
  if (t161){
    t162 = mem_malloc(40); ((cptr)t162)[0] = slicelst_methods;
    t163 = slicelst_alloc((cint)t162, (cint)list_self, (cint)2, (cint)((cptr)list_self)[3] /* len*/);
    list_sl = t163;
    t164 = ((cptr)(((cptr)list_oblst)[0]))[97];
    t165 = ((f0)t164)((cint)list_oblst, (cint)list_sl); /* Plus*/
    t128 = t165;
    goto t128_label;
  }else{
  t167 = list_i == ((cptr)list_self)[3] /* len*/;
  if (t167){
    t168 = mem_malloc(40); ((cptr)t168)[0] = slicelst_methods;
    t169 = ((cptr)list_self)[3] /* len*/ - 1;
    t170 = slicelst_alloc((cint)t168, (cint)list_self, (cint)1, (cint)t169);
    list_sl = t170;
    t171 = ((cptr)(((cptr)list_sl)[0]))[97];
    t172 = ((f0)t171)((cint)list_sl, (cint)list_oblst); /* Plus*/
    t128 = t172;
    goto t128_label;
  }else{
  t174 = 1 < list_i;
  t175 = t174;
  if (t175){
    t176 = list_i < ((cptr)list_self)[3] /* len*/;
    t175 = t176;
  };
  if (t175){
    t177 = mem_malloc(40); ((cptr)t177)[0] = slicelst_methods;
    t178 = list_i - 1;
    t179 = slicelst_alloc((cint)t177, (cint)list_self, (cint)1, (cint)t178);
    list_sl1 = t179;
    t180 = mem_malloc(40); ((cptr)t180)[0] = slicelst_methods;
    ((cptr)list_self)[1] += 1;
    t181 = list_i + 1;
    t182 = slicelst_alloc((cint)t180, (cint)list_self, (cint)t181, (cint)((cptr)list_self)[3] /* len*/);
    list_sl2 = t182;
    t183 = ((cptr)(((cptr)list_sl1)[0]))[97];
    t184 = ((f0)t183)((cint)list_sl1, (cint)list_oblst); /* Plus*/
    t186 = ((cptr)(((cptr)t184)[0]))[97];
    t187 = ((f0)t186)((cint)t184, (cint)list_sl2); /* Plus*/
    t128 = t187;
    goto t128_label;
  }else{
    t189 = ((cptr)list_self)[3] /* len*/ + 1;
    t190 = list_i == t189;
    if (t190){
      t191 = ((cptr)(((cptr)list_self)[0]))[97];
      t192 = ((f0)t191)((cint)list_self, (cint)list_oblst); /* Plus*/
      t128 = t192;
      goto t128_label;
    };
    t194 = mem_malloc(32); ((cptr)t194)[0] = ulist_methods;
    t195 = list_i - ((cptr)list_self)[3] /* len*/;
    t196 = t195 - 1;
    t197 = ulist_alloc((cint)t194, (cint)t196);
    list_ulst = t197;
    t198 = ((cptr)(((cptr)list_self)[0]))[97];
    t199 = ((f0)t198)((cint)list_self, (cint)list_ulst); /* Plus*/
    t201 = ((cptr)(((cptr)t199)[0]))[97];
    t202 = ((f0)t201)((cint)t199, (cint)list_oblst); /* Plus*/
    t128 = t202;
    goto t128_label;
  };};};};
  t128 = list_result;
  goto t128_label;
  t128_label: return t128;
}

void init_list(){
  copy_meth_table(list_methods, collection_methods);
  list_methods[0] = 32;
  list_methods[3] = list_alloc;
  list_methods[4] = list_reclaim;
  list_methods[6] = list_All_but_last;
  list_methods[11] = list_Ascending;
  list_methods[15] = list_Assign_to_component;
  list_methods[29] = list_Delete_ith;
  list_methods[30] = list_Descending;
  list_methods[37] = list_equal;
  list_methods[60] = list_less_than;
  list_methods[68] = list_Make_list;
  list_methods[88] = list_Mkstr;
  list_methods[97] = list_Plus;
  list_methods[106] = list_Tail;
  list_methods[130] = list_update;
}
