#include "cdefs.h"
#include "mem.h"
extern cptr object_methods[meth_max];
extern cptr string_methods[meth_max];
extern cptr sstring_methods[meth_max];
#include "cint.h"
#include "cstring.h"
#include "cfloat.h"
extern cptr strpool_methods[meth_max];
extern cptr float_methods[meth_max];

extern cint strpool_str_5;
extern cint object_Undefined;
extern cint strpool_str_19;


cptr integer_methods[meth_max];

cint integer_alloc(cint integer_self, cint integer_value){
  cint integer_result;
  cint t1, t2;
  t2 = object_alloc((cint)integer_self);
  integer_result = t2;
  ((cptr)integer_self)[4] /* class_of*/ = strpool_str_5;
  ((cptr)integer_self)[2] /* hashval*/ = cstring_str2int((cint)integer_value);
  t1 = integer_result;
  goto t1_label;
  t1_label: return t1;
}

cint integer_ialloc(cint integer_self, cint integer_value){
  cint integer_result;
  cint t3, t4;
  t4 = object_alloc((cint)integer_self);
  integer_result = t4;
  ((cptr)integer_self)[4] /* class_of*/ = strpool_str_5;
  ((cptr)integer_self)[2] /* hashval*/ = integer_value;
  t3 = integer_result;
  goto t3_label;
  t3_label: return t3;
}

cint integer_reclaim(cint integer_self){
  cint t5;
  object_reclaim((cint)integer_self);
  t5_label: return t5;
}

cint integer_copy_of(cint integer_self){
  cint integer_result;
  cint t6, t7, t8, t9;
  t7 = ((cptr)integer_self)[1] /* refcount*/ == 1;
  if (t7){
    t6 = integer_self;
    goto t6_label;
  };
  t8 = mem_malloc(28); ((cptr)t8)[0] = integer_methods;
  t9 = integer_ialloc((cint)t8, (cint)((cptr)integer_self)[2] /* hashval*/);
  integer_result = t9;
  object_Dec_ref(integer_self);
  t6 = integer_result;
  goto t6_label;
  t6_label: return t6;
}

cint integer_Divide(cint integer_self, cint integer_ob){
  cint integer_result;
  cint t10, t11, t12, t13, t14, t15;
  t11 = mem_malloc(32); ((cptr)t11)[0] = float_methods;
  t12 = float_ialloc((cint)t11, (cint)((cptr)integer_self)[2] /* hashval*/);
  t13 = ((cptr)(((cptr)t12)[0]))[31];
  t14 = ((f0)t13)((cint)t12, (cint)integer_ob); /* Divide*/
  integer_result = t14;
  object_Dec_ref(integer_self);
  t10 = integer_result;
  goto t10_label;
  t10_label: return t10;
}

cint integer_equal(cint integer_self, cint integer_ob){
  cint integer_result;
  cint t16, t17, t18, t19, t20, t21, t22;
  t17 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_5;
  if (t17){
    t18 = ((cptr)integer_self)[2] /* hashval*/ == ((cptr)integer_ob)[2] /* hashval*/;
    if (t18){
      t16 = 1;
      goto t16_label;
    };
    t16 = 0;
    goto t16_label;
  };
  t19 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_19;
  if (t19){
    t20 = ((cptr)(((cptr)integer_ob)[0]))[37];
    t21 = ((f0)t20)((cint)integer_ob, (cint)integer_self); /* equal*/
    t16 = t21;
    goto t16_label;
  };
  t16 = 0;
  goto t16_label;
  t16_label: return t16;
}

cint integer_Exponentiate(cint integer_self, cint integer_ob){
  cint integer_result, integer_f;
  cint t23, t24, t25, t26, t27, t28, t29;
  t24 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_5;
  if (t24){
    t25 = mem_malloc(32); ((cptr)t25)[0] = float_methods;
    t26 = float_falloc((cint)t25, (cint)cfloat_ii_pow((cint)((cptr)integer_self)[2] /* hashval*/, (cint)((cptr)integer_ob)[2] /* hashval*/));
    integer_result = t26;
  }else{
  t27 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_19;
  if (t27){
    integer_f = integer_ob;
    t28 = mem_malloc(32); ((cptr)t28)[0] = float_methods;
    t29 = float_falloc((cint)t28, (cint)cfloat_if_pow((cint)((cptr)integer_self)[2] /* hashval*/, (cint)((cptr)integer_f)[7] /* fval*/));
    integer_result = t29;
  }else{
    integer_result = object_Undefined;
  };};
  object_Dec_ref(integer_self);
  object_Dec_ref(integer_ob);
  t23 = integer_result;
  goto t23_label;
  t23_label: return t23;
}

cint integer_less_than(cint integer_self, cint integer_ob){
  cint integer_result;
  cint t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40;
  integer_result = 0;
  t31 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_5;
  if (t31){
    t32 = ((cptr)integer_self)[2] /* hashval*/ < ((cptr)integer_ob)[2] /* hashval*/;
    if (t32){
      t30 = 1;
      goto t30_label;
    };
  }else{
  t35 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_19;
  t36 = t35;
  if (t36){
  t33 = ((cptr)(((cptr)integer_ob)[0]))[37];
  t34 = ((f0)t33)((cint)integer_ob, (cint)integer_self); /* equal*/
    t37 = t34 == 0;
    t36 = t37;
  };
  if (t36){
    t38 = ((cptr)(((cptr)integer_ob)[0]))[60];
    t39 = ((f0)t38)((cint)integer_ob, (cint)integer_self); /* less_than*/
    t40 = t39 == 0;
    if (t40){
      t30 = 1;
      goto t30_label;
    };
  };};
  t30 = 0;
  goto t30_label;
  t30_label: return t30;
}

cint integer_make_div(cint integer_self, cint integer_ob){
  cint integer_result, integer_f;
  cint t41, t42, t43, t44, t45, t46, t47, t48, t49, t50;
  t42 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_5;
  t43 = t42;
  if (t43){
    t44 = ((cptr)integer_ob)[2] /* hashval*/ != 0;
    t43 = t44;
  };
  if (t43){
    t45 = mem_malloc(28); ((cptr)t45)[0] = integer_methods;
    t46 = integer_ialloc((cint)t45, (cint)cint_div((cint)((cptr)integer_self)[2] /* hashval*/, (cint)((cptr)integer_ob)[2] /* hashval*/));
    t41 = t46;
    goto t41_label;
  }else{
  t47 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_19;
  if (t47){
    integer_f = integer_ob;
    t48 = cint_as_float((cint)((cptr)integer_f)[7] /* fval*/) != 0;
    if (t48){
      t49 = mem_malloc(28); ((cptr)t49)[0] = integer_methods;
      t50 = integer_ialloc((cint)t49, (cint)cfloat_if_idiv((cint)((cptr)integer_self)[2] /* hashval*/, (cint)((cptr)integer_f)[7] /* fval*/));
      t41 = t50;
      goto t41_label;
    };
  };};
  t41 = object_Undefined;
  goto t41_label;
  t41_label: return t41;
}

cint integer_make_mod(cint integer_self, cint integer_ob){
  cint integer_result, integer_f;
  cint t51, t52, t53, t54, t55, t56, t57, t58, t59, t60;
  t52 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_5;
  t53 = t52;
  if (t53){
    t54 = ((cptr)integer_ob)[2] /* hashval*/ != 0;
    t53 = t54;
  };
  if (t53){
    t55 = mem_malloc(28); ((cptr)t55)[0] = integer_methods;
    t56 = integer_ialloc((cint)t55, (cint)cint_ii_mod((cint)((cptr)integer_self)[2] /* hashval*/, (cint)((cptr)integer_ob)[2] /* hashval*/));
    t51 = t56;
    goto t51_label;
  }else{
  t57 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_19;
  if (t57){
    integer_f = integer_ob;
    t58 = cint_as_float((cint)((cptr)integer_f)[7] /* fval*/) == 0;
    if (t58){
      t59 = mem_malloc(28); ((cptr)t59)[0] = integer_methods;
      t60 = integer_ialloc((cint)t59, (cint)cfloat_if_mod((cint)((cptr)integer_self)[2] /* hashval*/, (cint)((cptr)integer_f)[7] /* fval*/));
      t51 = t60;
      goto t51_label;
    };
  };};
  t51 = object_Undefined;
  goto t51_label;
  t51_label: return t51;
}

cint integer_make_rem(cint integer_self, cint integer_ob){
  cint integer_result, integer_f;
  cint t61, t62, t63, t64, t65, t66, t67, t68, t69, t70;
  t62 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_5;
  t63 = t62;
  if (t63){
    t64 = ((cptr)integer_ob)[2] /* hashval*/ != 0;
    t63 = t64;
  };
  if (t63){
    t65 = mem_malloc(28); ((cptr)t65)[0] = integer_methods;
    t66 = integer_ialloc((cint)t65, (cint)cint_rem((cint)((cptr)integer_self)[2] /* hashval*/, (cint)((cptr)integer_ob)[2] /* hashval*/));
    t61 = t66;
    goto t61_label;
  }else{
  t67 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_19;
  if (t67){
    integer_f = integer_ob;
    t68 = cint_as_float((cint)((cptr)integer_f)[7] /* fval*/) == 0;
    if (t68){
      t69 = mem_malloc(28); ((cptr)t69)[0] = integer_methods;
      t70 = integer_ialloc((cint)t69, (cint)cfloat_if_rem((cint)((cptr)integer_self)[2] /* hashval*/, (cint)((cptr)integer_f)[7] /* fval*/));
      t61 = t70;
      goto t61_label;
    };
  };};
  t61 = object_Undefined;
  goto t61_label;
  t61_label: return t61;
}

cint integer_Minus(cint integer_self, cint integer_ob){
  cint integer_result;
  cint t71, t72, t73, t74, t75, t76, t77, t78, t79, t80, t81;
  t72 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_5;
  if (t72){
    t73 = ((cptr)integer_self)[2] /* hashval*/ - ((cptr)integer_ob)[2] /* hashval*/;
    t74 = ((cptr)(((cptr)integer_self)[0]))[157];
    t75 = ((f0)t74)((cint)integer_self, (cint)integer_ob, (cint)t73); /* update_one*/
    t71 = t75;
    goto t71_label;
  };
  t77 = mem_malloc(32); ((cptr)t77)[0] = float_methods;
  t78 = float_ialloc((cint)t77, (cint)((cptr)integer_self)[2] /* hashval*/);
  t79 = ((cptr)(((cptr)t78)[0]))[83];
  t80 = ((f0)t79)((cint)t78, (cint)integer_ob); /* Minus*/
  integer_result = t80;
  object_Dec_ref(integer_self);
  t71 = integer_result;
  goto t71_label;
  t71_label: return t71;
}

cint integer_Mknum(cint integer_self){
  cint integer_result;
  cint t82;
  t82 = integer_self;
  goto t82_label;
  t82_label: return t82;
}

cint integer_Mkstr(cint integer_self){
  cint integer_result;
  cint t83, t84, t85;
  t84 = mem_malloc(40); ((cptr)t84)[0] = sstring_methods;
  t85 = sstring_alloc((cint)t84, (cint)cstring_int2str((cint)((cptr)integer_self)[2] /* hashval*/));
  integer_result = t85;
  object_Dec_ref(integer_self);
  t83 = integer_result;
  goto t83_label;
  t83_label: return t83;
}

cint integer_Multiply(cint integer_self, cint integer_ob){
  cint integer_result;
  cint t86, t87, t88, t89, t90, t91, t92, t93, t94, t95, t96;
  t87 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_5;
  if (t87){
    t88 = ((cptr)integer_self)[2] /* hashval*/ * ((cptr)integer_ob)[2] /* hashval*/;
    t89 = ((cptr)(((cptr)integer_self)[0]))[157];
    t90 = ((f0)t89)((cint)integer_self, (cint)integer_ob, (cint)t88); /* update_one*/
    t86 = t90;
    goto t86_label;
  };
  t92 = mem_malloc(32); ((cptr)t92)[0] = float_methods;
  t93 = float_ialloc((cint)t92, (cint)((cptr)integer_self)[2] /* hashval*/);
  t94 = ((cptr)(((cptr)t93)[0]))[89];
  t95 = ((f0)t94)((cint)t93, (cint)integer_ob); /* Multiply*/
  integer_result = t95;
  object_Dec_ref(integer_self);
  t86 = integer_result;
  goto t86_label;
  t86_label: return t86;
}

cint integer_Negate(cint integer_self){
  cint integer_result;
  cint t97, t98, t99, t100;
  t98 = ((cptr)(((cptr)integer_self)[0]))[109];
  t99 = ((f0)t98)((cint)integer_self, (cint)-((cptr)integer_self)[2] /* hashval*/); /* update_hashval*/
  t97 = t99;
  goto t97_label;
  t97_label: return t97;
}

cint integer_Plus(cint integer_self, cint integer_ob){
  cint integer_result;
  cint t101, t102, t103, t104, t105, t106, t107, t108, t109, t110, t111;
  t102 = ((cptr)integer_ob)[4] /* class_of*/ == strpool_str_5;
  if (t102){
    t103 = ((cptr)integer_self)[2] /* hashval*/ + ((cptr)integer_ob)[2] /* hashval*/;
    t104 = ((cptr)(((cptr)integer_self)[0]))[157];
    t105 = ((f0)t104)((cint)integer_self, (cint)integer_ob, (cint)t103); /* update_one*/
    t101 = t105;
    goto t101_label;
  };
  t107 = mem_malloc(32); ((cptr)t107)[0] = float_methods;
  t108 = float_ialloc((cint)t107, (cint)((cptr)integer_self)[2] /* hashval*/);
  t109 = ((cptr)(((cptr)t108)[0]))[97];
  t110 = ((f0)t109)((cint)t108, (cint)integer_ob); /* Plus*/
  integer_result = t110;
  object_Dec_ref(integer_self);
  t101 = integer_result;
  goto t101_label;
  t101_label: return t101;
}

cint integer_update_hashval(cint integer_self, cint integer_i){
  cint integer_result;
  cint t112, t113, t114, t115;
  t113 = ((cptr)(((cptr)integer_self)[0]))[21];
  t114 = ((f0)t113)((cint)integer_self); /* copy_of*/
  integer_result = t114;
  ((cptr)integer_result)[2] /* hashval*/ = integer_i;
  t112 = integer_result;
  goto t112_label;
  t112_label: return t112;
}

cint integer_update_one(cint integer_self, cint integer_ob, cint integer_val){
  cint integer_result;
  cint t116, t117, t118, t119, t120, t121, t122, t123;
  t117 = ((cptr)integer_ob)[1] /* refcount*/ == 1;
  if (t117){
    object_Dec_ref(integer_self);
    t118 = ((cptr)(((cptr)integer_ob)[0]))[109];
    t119 = ((f0)t118)((cint)integer_ob, (cint)integer_val); /* update_hashval*/
    t116 = t119;
    goto t116_label;
  };
  object_Dec_ref(integer_ob);
  t121 = ((cptr)(((cptr)integer_self)[0]))[109];
  t122 = ((f0)t121)((cint)integer_self, (cint)integer_val); /* update_hashval*/
  t116 = t122;
  goto t116_label;
  t116_label: return t116;
}

void init_integer(){
  copy_meth_table(integer_methods, object_methods);
  integer_methods[0] = 28;
  integer_methods[3] = integer_alloc;
  integer_methods[153] = integer_ialloc;
  integer_methods[4] = integer_reclaim;
  integer_methods[21] = integer_copy_of;
  integer_methods[31] = integer_Divide;
  integer_methods[37] = integer_equal;
  integer_methods[42] = integer_Exponentiate;
  integer_methods[60] = integer_less_than;
  integer_methods[154] = integer_make_div;
  integer_methods[155] = integer_make_mod;
  integer_methods[156] = integer_make_rem;
  integer_methods[83] = integer_Minus;
  integer_methods[87] = integer_Mknum;
  integer_methods[88] = integer_Mkstr;
  integer_methods[89] = integer_Multiply;
  integer_methods[92] = integer_Negate;
  integer_methods[97] = integer_Plus;
  integer_methods[109] = integer_update_hashval;
  integer_methods[157] = integer_update_one;
}
